Thread (22 messages) flat view 22 messages, 2 authors, 5d ago

Re: [PATCH 08/14] objtool/klp,livepatch: Resolve module symbols against core kallsyms

From: Josh Poimboeuf <jpoimboe@kernel.org>
Date: 2026-08-03 06:26:07
Also in: live-patching, lkml

On Sun, Aug 02, 2026 at 08:24:30PM -0700, Josh Poimboeuf wrote:
For patching a module, klp_find_sympos() counts every symbol table entry
whose name matches.  However, the module loader only includes symbols
matched by is_core_symbol().

The runtime count is inconsistent as well.  It's done by
module_kallsyms_on_each_symbol(), which iterates the full init symbol
table until do_init_module() swaps in the cut-down core table, so the
same symbol can have different positions depending on whether init
memory has been freed yet.

Define a module's sympos as its position in the core symbol table, which
is what sympos already means for a live module and what users see in
/proc/kallsyms.  Enforce that on both ends: count with
module_kallsyms_on_each_core_symbol() at runtime, and mirror the
is_core_symbol() filter in objtool with a new mod_sym_in_kallsyms()
helper.

The init-layout half of the filter is only correct if .exit sections are
core sections, which requires CONFIG_MODULE_UNLOAD, otherwise .exit code
is laid out as part of init memory and freed after module init.  Enforce
CONFIG_MODULE_UNLOAD to ensure that behavior is deterministic.

Symbols which exist only in init sections are no longer resolvable, but
they never were once the module went live, and init memory is freed
after module init anyway.

Fixes: dd590d4d57eb ("objtool/klp: Introduce klp diff subcommand for diffing object files")
Fixes: b2b018ef4867 ("livepatch: add old_sympos as disambiguator field to klp_func")
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
NAK - as mentioned for the previous patch, this is a theoretical edge
case which I will fix in a different way.

-- 
Josh
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help