[PATCH 2/4] objtool/klp: allow new references to module exports

Joe Lawrence <[email protected]> Mon, 20 Jul 2026 10:56:56 -0400
Newsgroups org.kernel.vger.live-patching
Message-ID <[email protected]>
klp_reloc_needed() returns true for module exports to support
late-module patching.  However, clone_reloc_klp() unconditionally
rejects symbols without a twin (i.e., new references added by the
patch), even when the symbol is a known export from Module.symvers.

Relax the check: allow new references to exported symbols by only
erroring on !twin when there is no export.  The export metadata from
Module.symvers provides sufficient context to emit the klp-relocation
without a twin.

Signed-off-by: Joe Lawrence <[email protected]>
---
 tools/objtool/klp-diff.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/objtool/klp-diff.c b/tools/objtool/klp-diff.c
index c5cc54ee562e..e14d1f32126d 100644
--- a/tools/objtool/klp-diff.c
+++ b/tools/objtool/klp-diff.c
@@ -1528,7 +1528,7 @@ static int clone_reloc_klp(struct elfs *e, struct reloc *patched_reloc,
 	unsigned long sympos;
 	s64 str_addend;
 
-	if (!patched_sym->twin) {
+	if (!patched_sym->twin && !export) {
 		ERROR("unexpected klp reloc for new symbol %s", patched_sym->name);
 		return -1;
 	}
-- 
2.54.0