Thread (3 messages) flat view 3 messages, 2 authors, 19h ago

Re: [PATCH] objtool/klp: Fix missed changes to same-named symbol references

From: sashiko-bot@kernel.org
Date: 2026-09-10 09:02:05
Also in: lkml

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] `__checksum_update_object_symbol()` unintentionally hashes the `offset` parameter (the relocation's position in the object) using `sizeof(offset)`. Since `offset` is an `unsigned long`, this introduces host-dependent hashing (4 bytes on 32-bit hosts, 8 bytes on 64-bit hosts), which breaks reproducible builds when cross-compiling. Furthermore, this behavior is inconsistent with `__checksum_update_object()` (used for string section relocations), which only uses the offset for debugging and does not hash it.
--

commit 84526b95607bbfd01a9cb5c2ebf122ffa01327c1
Author: Longjun Luo [off-list ref]

objtool/klp: Fix missed changes to same-named symbol references

This commit modifies objtool to hash referenced symbols using both the
filename and the demangled name. This aims to prevent false negatives
when a function or data object changes its target to a same-named
static function.
quoted hunk ↗ jump to hunk
diff --git a/tools/objtool/include/objtool/checksum.h b/tools/objtool/include/objtool/checksum.h
index d46293f547166..1834d34dfd478 100644
--- a/tools/objtool/include/objtool/checksum.h
+++ b/tools/objtool/include/objtool/checksum.h
[ ... ]
quoted hunk ↗ jump to hunk
@@ -38,6 +56,15 @@ static inline void __checksum_update_object(struct symbol *sym,
 	dbg_checksum_object(sym, offset, what, XXH3_64bits_digest(sym->csum.state));
 }
 
+static inline void __checksum_update_object_symbol(struct symbol *sym,
+						   unsigned long offset,
+						   struct symbol *target)
+{
+	__checksum_update(sym, &offset, sizeof(offset));
[Severity: Medium]
Can hashing the offset parameter here introduce host-dependent behavior?

Since offset is an unsigned long, sizeof(offset) is 4 bytes on 32-bit hosts
and 8 bytes on 64-bit hosts. This can cause the generated livepatch checksums
to vary depending on the build host, which breaks reproducible builds when
cross-compiling.

Before this change, __checksum_update_object() received sym_offset but only
used it for debugging output without hashing it. Should this offset be
excluded from the hash calculation here as well to ensure consistent
checksums across different build hosts?
+	__checksum_update_symbol_identity(sym, target);
+	dbg_checksum_object(sym, offset, "reloc name", XXH3_64bits_digest(sym->csum.state));
+}
+
quoted hunk ↗ jump to hunk
diff --git a/tools/objtool/klp-checksum.c b/tools/objtool/klp-checksum.c
index b8e47f28997e9..3da3fe11bf762 100644
--- a/tools/objtool/klp-checksum.c
+++ b/tools/objtool/klp-checksum.c
[ ... ]
quoted hunk ↗ jump to hunk
@@ -206,9 +203,7 @@ static void checksum_update_object(struct objtool_file *file, struct symbol *sym
 			offset -= target->offset;
 		}
 
-		__checksum_update_object(sym, sym_offset, "reloc name",
-					 target->demangled_name,
-					 strlen(target->demangled_name));
+		__checksum_update_object_symbol(sym, sym_offset, target);
 		__checksum_update_object(sym, sym_offset, "reloc addend",
 					 &offset, sizeof(offset));
 	}
-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260910085218.66565-1-luolongjuna@gmail.com?part=1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help