[Devel] [PATCH hci-8.2 6/6] ms/objtool/klp: Fix checksums for constant pool references
no-reply at sashiko.virtuozzo.com
no-reply at sashiko.virtuozzo.com
Tue Dec 1 03:45:38 MSK 2026
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] objtool: unchecked sh_entsize-byte hash read in anonymous const
data checksum
--
commit 6c01ff96123a5a330a3e5f3c2a72de8401de72c0
Author: Josh Poimboeuf <jpoimboe at kernel.org>
ms/objtool/klp: Fix checksums for constant pool references
When a function references an .LC* symbol or anonymous data in a .rodata.cst<num> section, the checksum now covers the constant's contents instead of the symbol name. This avoids false "changed function" reports when the compiler renumbers .LC symbols.
Link: https://patch.msgid.link/f3a9e74ceebc6475ce94bcfe985401140857814a.1787939301.git.jpoimboe@kernel.org
> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> index 403da0d3739a6..17d6735032408 100644
> --- a/tools/objtool/check.c
> +++ b/tools/objtool/check.c
> @@ -3665,6 +3678,14 @@ static void checksum_update_insn(struct objtool_file *file, struct symbol *func,
> return;
> }
>
> + if (is_anonymous_const_data(sym)) {
> + void *cst;
> +
> + cst = sym->sec->data->d_buf + sym->offset + offset;
> + checksum_update(func, insn, cst, sym->sec->sh.sh_entsize);
> + return;
> + }
> +
[Severity: Low]
Can this read past the intended constant? The pointer is d_buf + sym->offset + offset, and a fixed sh_entsize bytes are hashed from it, with no check against the section size and no check that the offset is entry-aligned.
If a relocation addend points into the middle of a .rodata.cst<N> entry, such as .LC0+8 for a 16-byte constant, the hash covers part of the next constant. For the last entry it reads past the end of the section buffer. The result is a wrong checksum, which means a spurious or missed changed-function report, or a small heap over-read in the tool.
Would it be worth validating that the offset plus sh_entsize stays within sh_size, and that sh_entsize is non-zero, before hashing?
Carry the trailer below into the next revision and Sashiko will not review this patch again.
Reviewed-by: Sashiko <no-reply at sashiko.virtuozzo.com>
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261126-khorenko-vstor-157128-more-klp-build-fixes-v1-0-69a0363954e4@virtuozzo.com?part=6
More information about the Devel
mailing list