mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: x86@kernel.org, "Josh Poimboeuf" <jpoimboe@kernel.org>
Cc: "Petr Mladek" <pmladek@suse.com>,
	"Joe Lawrence" <joe.lawrence@redhat.com>,
	linux-kernel@vger.kernel.org, live-patching@vger.kernel.org,
	"Song Liu" <song@kernel.org>, "Miroslav Benes" <mbenes@suse.cz>,
	"Peter Zijlstra" <peterz@infradead.org>
Subject: Re: [PATCH v2] objtool/klp: Fix checksums for constant pool references
Date: Fri, 28 Aug 2026 17:59:35 +0000	[thread overview]
Message-ID: <20260828175935.AA3E21F000E9@smtp.kernel.org> (raw)
In-Reply-To: <f3a9e74ceebc6475ce94bcfe985401140857814a.1787939301.git.jpoimboe@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The checksum calculation for anonymous constants does not align the relocation addend, potentially reading past the end of the constant and out-of-bounds of the section.
--

commit 40a0e3ccdee64d957ccae4cb27dbc7318ac09355
Author: Josh Poimboeuf <jpoimboe@kernel.org>

objtool/klp: Fix checksums for constant pool references

This commit addresses false positive changed functions in livepatches by
including the underlying data of anonymous constant pool references in the
objtool checksum calculation, rather than relying on arbitrary symbol names.

> diff --git a/tools/objtool/klp-checksum.c b/tools/objtool/klp-checksum.c
> index b8e47f28997e9..ebe25f9c5260a 100644
> --- a/tools/objtool/klp-checksum.c
> +++ b/tools/objtool/klp-checksum.c

[ ... ]

> @@ -129,6 +142,14 @@ static void checksum_update_insn(struct objtool_file *file, struct symbol *func,
>  		goto alts;
>  	}
>  
> +	if (is_anonymous_const_data(sym)) {
> +		void *cst;
> +
> +		cst = sym->sec->data->d_buf + sym->offset + offset;
> +		__checksum_update_insn(func, insn, cst, sym->sec->sh.sh_entsize);

[Severity: Medium]
Could this result in an out-of-bounds read if the relocation addend is
unaligned?

In checksum_update_insn(), the code calculates the cst pointer by adding the
potentially unaligned offset to the symbol base, but then unconditionally
hashes a full sym->sec->sh.sh_entsize bytes.

If the compiler emits a relocation to a constant pool section with an
unaligned addend (for example, when an instruction accesses a sub-element of
a 16-byte constant), reading a full sh_entsize bytes from a mid-constant
offset could cross the section buffer boundary if this constant is at the
end of the section.

Can this lead to non-deterministic checksums by incorporating unrelated memory
into the hash, or potentially cause a segfault during the kernel build?

> +		goto alts;
> +	}
> +
>  	if (is_sec_sym(sym)) {
>  		sym = find_symbol_containing(reloc->sym->sec, offset);
>  		if (!sym)

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/f3a9e74ceebc6475ce94bcfe985401140857814a.1787939301.git.jpoimboe@kernel.org?part=1

  reply	other threads:[~2026-08-28 17:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-28 17:48 Josh Poimboeuf
2026-08-28 17:59 ` sashiko-bot [this message]
2026-08-28 18:21   ` Josh Poimboeuf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260828175935.AA3E21F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=joe.lawrence@redhat.com \
    --cc=jpoimboe@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=live-patching@vger.kernel.org \
    --cc=mbenes@suse.cz \
    --cc=peterz@infradead.org \
    --cc=pmladek@suse.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=song@kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®