]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commit
objtool/klp: Fix detection of corrupt static branch/call entries
authorJosh Poimboeuf <jpoimboe@kernel.org>
Tue, 10 Feb 2026 21:50:09 +0000 (13:50 -0800)
committerJosh Poimboeuf <jpoimboe@kernel.org>
Fri, 6 Mar 2026 15:47:10 +0000 (07:47 -0800)
commitf9fb44b0ecefc1f218db56661ed66d4e8d67317d
tree63bf2ef1e61fab4e09beb0963ef9c6da57887fa5
parent11439c4635edd669ae435eec308f4ab8a0804808
objtool/klp: Fix detection of corrupt static branch/call entries

Patching a function which references a static key living in a kernel
module is unsupported due to ordering issues inherent to late module
patching:

  1) Load a livepatch module which has a __jump_table entry which needs
     a klp reloc to reference static key K which lives in module M.

  2) The __jump_table klp reloc does *not* get resolved because module M
     is not yet loaded.

  3) jump_label_add_module() corrupts memory (or causes a panic) when
     dereferencing the uninitialized pointer to key K.

validate_special_section_klp_reloc() intends to prevent that from ever
happening by catching it at build time.  However, it incorrectly assumes
the special section entry's reloc symbol references have already been
converted from section symbols to object symbols, causing the validation
to miss corruption in extracted static branch/call table entries.

Make sure the references have been properly converted before doing the
validation.

Fixes: dd590d4d57eb ("objtool/klp: Introduce klp diff subcommand for diffing object files")
Reported-by: Song Liu <song@kernel.org>
Reviewed-and-tested-by: Song Liu <song@kernel.org>
Link: https://patch.msgid.link/124ad747b751df0df1725eff89de8332e3fb26d6.1770759954.git.jpoimboe@kernel.org
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
tools/objtool/klp-diff.c