Re: [PATCH] objtool/klp: Fix missed changes to same-named symbol references
From: sashiko-bot
Date: Thu Sep 10 2026 - 05:13:08 EST
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 <luolongjuna@xxxxxxxxx>
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.
> 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
[ ... ]
> @@ -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));
> +}
> +
> 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
[ ... ]
> @@ -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@xxxxxxxxx?part=1