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

Josh Poimboeuf <[email protected]> Sun, 2 Aug 2026 23:26:05 -0700
Newsgroups org.kernel.vger.linux-modules,org.kernel.vger.linux-kernel,org.kernel.vger.live-patching
Message-ID <ho6yp23ka6ibblqowzbe3axjlczrsqy23gdd57unsq5zd6urrh@h5if7q7at45r>
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 <[email protected]>

NAK - as mentioned for the previous patch, this is a theoretical edge
case which I will fix in a different way.

-- 
Josh