]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
objtool/klp: Fix kCFI prefix finding/cloning
authorJosh Poimboeuf <jpoimboe@kernel.org>
Tue, 28 Apr 2026 04:15:52 +0000 (21:15 -0700)
committerJosh Poimboeuf <jpoimboe@kernel.org>
Tue, 5 May 2026 04:16:07 +0000 (21:16 -0700)
commitf7ceffd21a8a59ba1e92078750eef86e628dea80
tree4973f2eb95ebb166ee2d9769e00592c21724afcc
parentfc0bb9915bce0c333f918ca76958d804ccd79f89
objtool/klp: Fix kCFI prefix finding/cloning

With CFI+CALL_PADDING, Clang places .Ltmp labels at the start of the NOP
padding (offset 5) between the __cfi_ prefix and the function entry
point.  get_func_prefix() only checks the immediately previous symbol,
so the intervening .Ltmp label causes it to miss the __cfi_ prefix
symbol.

This results in klp-diff not cloning the kCFI type hash into the
livepatch module, causing a CFI failure at module load when calling
callback functions through indirect calls:

  CFI failure at __klp_enable_patch+0xab/0x140
    (target: pre_patch_callback+0x0/0x80 [livepatch_combined];
     expected type: 0xde073954)

Instead of walking backward through the section's symbol list, just use
find_func_containing() for the byte before the function.  This works now
that __cfi_ symbols are being grown by objtool to fill the padding.

Acked-by: Song Liu <song@kernel.org>
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
tools/objtool/include/objtool/elf.h