On Fri, Aug 7, 2026 at 2:38 PM Josh Poimboeuf <[email protected]> wrote: > > EXPORT_SYMBOL_FOR_MODULES() puts a symbol in a "module:<names>" > namespace, which the module loader grants access to by matching the > importing module's name against that list. > > klp_reloc_needed() only creates a klp reloc for module-owned exports; a > vmlinux export gets a normal reloc. For a vmlinux symbol exported with > EXPORT_SYMBOL_FOR_MODULES(), using a normal reloc results in a modpost > failure in klp-build: > > ERROR: modpost: module livepatch-foo uses symbol mpol_shared_policy_lookup > from namespace module:kvm, but does not import it. > > And the modpost error is correct: even with that error removed, the > patch module would fail to load: > > livepatch_foo: module uses symbol (mpol_shared_policy_lookup) from > namespace module:kvm, but does not import it. > livepatch_foo: Unknown symbol mpol_shared_policy_lookup (err -22) > > Treat it like an unexported symbol by using a klp reloc. > > Note this only affects "module:" namespaces. Ordinary namespaced > exports continue to work with normal relocs thanks to copy_import_ns(), > which propagates the patched object's import_ns tags to the patch > module. > > Fixes: dd590d4d57eb ("objtool/klp: Introduce klp diff subcommand for diffing > object files") > Reported-by: Joe Lawrence <[email protected]> > Link: https://lore.kernel.org/[email protected] > Signed-off-by: Josh Poimboeuf <[email protected]>
Acked-by: Song Liu <[email protected]>

