Re: [PATCH] objtool/klp: Fix vmlinux klp relocations for EXPORT_SYMBOL_FOR_MODULES()
Song Liu <[email protected]>
| Newsgroups | org.kernel.vger.live-patching,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <CAPhsuW7kHtrhaXRaBmdh69FCcM7tbnVOVBkjn67_x_nJK6Z8QA@mail.gmail.com> |
On Fri, Aug 14, 2026 at 7:36 PM Josh Poimboeuf <[email protected]> wrote: > > When a module function references a vmlinux symbol which is exported > with EXPORT_SYMBOL_FOR_MODULES(), a patch to that function needs to use > a klp reloc. > > Currently, livepatch fails to load such a module: > > livepatch: invalid access to vmlinux symbol 'get_task_policy' from module-specific livepatch relocation section > livepatch: failed to initialize patch 'livepatch_test' for module 'testmod' (-22) > livepatch: patch 'livepatch_test' failed for module 'testmod', refusing to load module 'testmod' > > klp diff puts all klp relocs in __klp_relocs.<patched object>, so > post-link names the section .klp.rela.<patched object>.<secname>, which the > kernel rejects for vmlinux symbols. > > Commit 07f14d6af9d77 ("objtool/klp: Fix cross-module klp relocation > section naming") changed the meaning of objname in the klp rela section > name to be where the referenced symbol is referenced rather than where > it lives. That premise only holds for symbols in a module: the relocs > get applied when the patched module gets patched, and the module > dependency guarantees the referenced module is loaded by then. > > A vmlinux symbol needs the opposite. It's always resolvable, and it has > to be applied when the patch module loads, before the module loader > initializes the patch module's special sections, which may reference it. > That's why livepatch rejects vmlinux symbols in module-specific > sections. > > Use "vmlinux" as the section objname when the referenced symbol lives in > vmlinux. This moves such klp relocs from .klp.rela.kvm..text to > .klp.rela.vmlinux..text. > > Fixes: 07f14d6af9d77 ("objtool/klp: Fix cross-module klp relocation section naming") > Reported-by: Dylan Hatch <[email protected]> > Closes: https://lore.kernel.org/CADBMgpz7iWC0=t=_gE-tfvv0mTPq4kg0qQ2zgPH8DVPE6eQ9Kw@mail.gmail.com > Signed-off-by: Josh Poimboeuf <[email protected]> Acked-by: Song Liu <[email protected]>