]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
x86/boot: Disable jump tables in PIC code
authorArd Biesheuvel <ardb@kernel.org>
Tue, 22 Apr 2025 21:05:11 +0000 (23:05 +0200)
committerIngo Molnar <mingo@kernel.org>
Wed, 23 Apr 2025 07:30:57 +0000 (09:30 +0200)
commit121c335b36e02d6aefb72501186e060474fdf33c
treef4cb0ef880312028d8044569c09616aa24b8416c
parentff4c0560ab020d34baf0aa6434f66333d25ae524
x86/boot: Disable jump tables in PIC code

objtool already struggles to identify jump tables correctly in non-PIC
code, where the idiom is something like

  jmpq  *table(,%idx,8)

and the table is a list of absolute addresses of jump targets.

When using -fPIC, both the table reference as well as the jump targets
are emitted in a RIP-relative manner, resulting in something like

  leaq    table(%rip), %tbl
  movslq  (%tbl,%idx,4), %offset
  addq    %offset, %tbl
  jmpq    *%tbl

and the table is a list of offsets of the jump targets relative to the
start of the entire table.

Considering that this sequence of instructions can be interleaved with
other instructions that have nothing to do with the jump table in
question, it is extremely difficult to infer the control flow by
deriving the jump targets from the indirect jump, the location of the
table and the relative offsets it contains.

So let's not bother and disable jump tables for code built with -fPIC
under arch/x86/boot/startup.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: linux-efi@vger.kernel.org
Link: https://lore.kernel.org/r/20250422210510.600354-2-ardb+git@google.com
arch/x86/boot/startup/Makefile