Re: [PATCH 1/4] objtool/klp: use patched module name for klp-relocation section naming
Josh Poimboeuf <[email protected]> Sun, 2 Aug 2026 20:03:59 -0700
| Newsgroups | org.kernel.vger.live-patching |
|---|---|
| Message-ID | <gte6frofwqfzedcqq5juvuszopk4tobooz7iycqigqgjadwsmc@j6v57ud4aq7a> |
On Mon, Jul 20, 2026 at 10:56:55AM -0400, Joe Lawrence wrote:
> Documentation/livepatch/module-elf-format.rst states (and the kernel
> currently implements) that the name of a livepatch relocation section
> must conform to the following format:
>
> .klp.rela.objname.section_name
>
> where "objname" determines when the kernel applies the relocations in
> this section (i.e., when the "objname" module loads). This allows
> relocations not only for currently loaded kernel objects (like vmlinux
> and loaded device drivers), but also for lazy resolution to facilitate
> late-module livepatching (for modules loaded after the livepatch).
>
> Previously, objtool's KLP post-link step derived the "objname" from the
> klp symbol name, which encoded where the symbol *lives* rather than
> which module is being *patched*. This broke cross-module references
> (e.g., can_isotp.ko calling can_rx_unregister() from can.ko),
> incorrectly placing them in the .klp.rela.can..text section instead of
> .klp.rela.can_isotp..text.
>
> Fix this by adding an 'obj_name' field to the intermediate 'klp_reloc'
> struct. klp-diff populates this field using find_modname(), and
> klp-post-link reads it directly to generate the .klp.rela section name.
> As a result, each relocation correctly carries its own target module,
> regardless of where the referenced symbol originates.
>
> Fixes: dd590d4d57eb ("objtool/klp: Introduce klp diff subcommand for diffing object files")
> Signed-off-by: Joe Lawrence <[email protected]>
I fixed this one a different way by putting the objname in the section
name: __klp_relocs.<objname>. Will post the patches soon.
--
Josh