ARM: backtrace-clang: avoid crash on bogus frame pointer
authorArd Biesheuvel <ardb@kernel.org>
Fri, 15 Oct 2021 14:27:09 +0000 (16:27 +0200)
committerArd Biesheuvel <ardb@kernel.org>
Fri, 3 Dec 2021 14:11:31 +0000 (15:11 +0100)
commiteae9523fdd7a6c592e80666681962acbd913cda2
tree16e293d6b1d12f0e5253407adc48d36c93547068
parent4ab6827081c63b83011a18d8e27f621ed34b1194
ARM: backtrace-clang: avoid crash on bogus frame pointer

The Clang backtrace code dereferences the link register value pulled
from the stack to decide whether the caller was a branch-and-link
instruction, in order to subsequently decode the offset to find the
start of the calling function. Unlike other loads in this routine, this
one is not protected by a fixup, and may therefore cause a crash if the
address in question is bogus.

So let's fix this, by treating the fault as a failure to decode the 'bl'
instruction. To avoid a label renum, reuse a fixup label that guards an
instruction that cannot fault to begin with.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Marc Zyngier <maz@kernel.org>
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com> # ARMv7M
arch/arm/lib/backtrace-clang.S