Thread (22 messages) flat view 22 messages, 2 authors, 6d ago

Re: [PATCH 05/14] objtool/klp: Add .klp.symid for sympos disambiguation

From: Josh Poimboeuf <jpoimboe@kernel.org>
Date: 2026-08-03 05:42:35

On Mon, Aug 03, 2026 at 03:41:15AM +0000, sashiko-bot@kernel.org wrote:
quoted hunk ↗ jump to hunk
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Relocations in .klp.symid pointing to discarded sections (.exitcall.exit, .exit.text, etc.) will cause a link-time error when building vmlinux.
--
--- Patch [5]: [PATCH 05/14] objtool/klp: Add .klp.symid for sympos disambiguation ---
commit 09454266fcd41f3c022cac215ab86d1269c37d52
Author: Josh Poimboeuf [off-list ref]

objtool/klp: Add .klp.symid for sympos disambiguation

This commit introduces a new .klp.symid section to vmlinux.o to help
livepatch reliably determine the sympos of duplicate-named symbols. It
emits an array of identifiers and relocations that survives the final link,
allowing klp-diff to correlate symbols between vmlinux.o and vmlinux.
quoted
diff --git a/tools/objtool/klp-symid.c b/tools/objtool/klp-symid.c
new file mode 100644
index 0000000000000..cf188cdfa6079
--- /dev/null
+++ b/tools/objtool/klp-symid.c
[ ... ]
quoted
+static const char * const discarded_secs[] = {
+	".discard",
+	".modinfo",
+	"__tracepoint_check",
+};
+
+static bool discarded_sec(struct section *sec)
+{
+	if (!(sec->sh.sh_flags & SHF_ALLOC))
+		return true;
+
+	for (int i = 0; i < ARRAY_SIZE(discarded_secs); i++)
+		if (strstarts(sec->name, discarded_secs[i]))
+			return true;
+
+	return false;
+}
[Severity: Low]
Should the discarded_secs array also include .exitcall.exit and .exit.
sections?

Because these exit sections have the SHF_ALLOC flag set, the first check in
discarded_sec() will not catch them. If they are also omitted from the
discarded_secs array, klp_create_symid_sections() will mistakenly generate
relocations pointing to them.

Since the linker script unconditionally discards .exitcall.exit via the
DISCARDS macro, generating relocations against it causes a deterministic
link-time error ("relocation refers to a discarded section") when building
vmlinux.

Could this happen in practice? Common driver exit handlers (e.g.,
module_cleanup used by drivers like cx18 and ivtv) often result in
duplicate static symbols like __exitcall_module_cleanup in the
.exitcall.exit section when the modules are built-in.
I'm not convinced this can happen in practice.  Why would somebody be
trying to patch or reference a module exit symbol anyway?

-- 
Josh
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help