mbox series

[0/3] arm64: Dynamic shadow call stack fixes

Message ID 20241106185513.3096442-5-ardb+git@google.com (mailing list archive)
Headers show
Series arm64: Dynamic shadow call stack fixes | expand

Message

Ard Biesheuvel Nov. 6, 2024, 6:55 p.m. UTC
From: Ard Biesheuvel <ardb@kernel.org>

When building modules using the large code model, the emitted DWARF
metadata uses large fields for the code references too, and this is
currently not being handled. 

The CIE header frame contains metadata that describes the size of these
fields, and so this should be parsed and taken into account when
processing the FDE frames (patch #2)

But first, the handling of this CIE frame header needs to be fixed, as
it currently [inadvertently] used hardcoded defaults for some values
that happen to always match what Clang emits in practice (patch #1) 

Cc: Sami Tolvanen <samitolvanen@google.com>
Cc: Kees Cook <kees@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>

Ard Biesheuvel (3):
  arm64/scs: Fix handling of DWARF augmentation data in CIE/FDE frames
  arm64/scs: Deal with 64-bit relative offsets in FDE frames
  arm64/scs: Drop unused prototype __pi_scs_patch_vmlinux()

 arch/arm64/include/asm/scs.h     |  8 +-
 arch/arm64/kernel/module.c       | 10 ++-
 arch/arm64/kernel/pi/patch-scs.c | 93 ++++++++++++++------
 3 files changed, 80 insertions(+), 31 deletions(-)

Comments

Sami Tolvanen Nov. 6, 2024, 10:13 p.m. UTC | #1
Hi Ard,

On Wed, Nov 6, 2024 at 6:55 PM Ard Biesheuvel <ardb+git@google.com> wrote:
>
> From: Ard Biesheuvel <ardb@kernel.org>
>
> When building modules using the large code model, the emitted DWARF
> metadata uses large fields for the code references too, and this is
> currently not being handled.
>
> The CIE header frame contains metadata that describes the size of these
> fields, and so this should be parsed and taken into account when
> processing the FDE frames (patch #2)
>
> But first, the handling of this CIE frame header needs to be fixed, as
> it currently [inadvertently] used hardcoded defaults for some values
> that happen to always match what Clang emits in practice (patch #1)
>
> Cc: Sami Tolvanen <samitolvanen@google.com>
> Cc: Kees Cook <kees@kernel.org>
> Cc: Nathan Chancellor <nathan@kernel.org>
>
> Ard Biesheuvel (3):
>   arm64/scs: Fix handling of DWARF augmentation data in CIE/FDE frames
>   arm64/scs: Deal with 64-bit relative offsets in FDE frames
>   arm64/scs: Drop unused prototype __pi_scs_patch_vmlinux()
>
>  arch/arm64/include/asm/scs.h     |  8 +-
>  arch/arm64/kernel/module.c       | 10 ++-
>  arch/arm64/kernel/pi/patch-scs.c | 93 ++++++++++++++------
>  3 files changed, 80 insertions(+), 31 deletions(-)

I was able to reproduce the issue by building modules with
-mcmodel=large, and I confirmed that this series fixes it. For the
series:

Reviewed-by: Sami Tolvanen <samitolvanen@google.com>
Tested-by: Sami Tolvanen <samitolvanen@google.com>

Sami