]> www.infradead.org Git - users/jedix/linux-maple.git/commit
objtool: Detect non-relocated text references
authorJosh Poimboeuf <jpoimboe@kernel.org>
Fri, 4 Oct 2024 00:31:10 +0000 (17:31 -0700)
committerJosh Poimboeuf <jpoimboe@kernel.org>
Thu, 17 Oct 2024 22:13:06 +0000 (15:13 -0700)
commited1cb76ebdeb88cf0603b9cb543f43f09ab704a1
treee6f84a90eb99077c09690c95ca42dc88f4da6921
parent8e929cb546ee42c9a61d24fae60605e9e3192354
objtool: Detect non-relocated text references

When kernel IBT is enabled, objtool detects all text references in order
to determine which functions can be indirectly branched to.

In text, such references look like one of the following:

   mov    $0x0,%rax        R_X86_64_32S     .init.text+0x7e0a0
   lea    0x0(%rip),%rax   R_X86_64_PC32    autoremove_wake_function-0x4

Either way the function pointer is denoted by a relocation, so objtool
just reads that.

However there are some "lea xxx(%rip)" cases which don't use relocations
because they're referencing code in the same translation unit.  Objtool
doesn't have visibility to those.

The only currently known instances of that are a few hand-coded asm text
references which don't actually need ENDBR.  So it's not actually a
problem at the moment.

However if we enable -fpie, the compiler would start generating them and
there would definitely be bugs in the IBT sealing.

Detect non-relocated text references and handle them appropriately.

[ Note: I removed the manual static_call_tramp check -- that should
  already be handled by the noendbr check. ]

Reported-by: Ard Biesheuvel <ardb@kernel.org>
Tested-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
arch/x86/kernel/acpi/wakeup_64.S
arch/x86/kernel/head_64.S
tools/objtool/arch/x86/decode.c
tools/objtool/check.c
tools/objtool/include/objtool/arch.h