From: bot+bpf-ci@kernel.org
To: blum@kernel.org,akpm@linux-foundation.org,song@kernel.org,jolsa@kernel.org,ihor.solodrai@linux.dev,ast@kernel.org,daniel@iogearbox.net,andrii@kernel.org,eddyz87@gmail.com,memxor@gmail.com,martin.lau@linux.dev,yonghong.song@linux.dev,emil@etsalapatis.com
Cc: blum@kernel.org,bpf@vger.kernel.org,linux-kernel@vger.kernel.org,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,mason@kernel.org,ihor.solodrai@linux.dev
Subject: Re: [PATCH bpf-next v2] lib/buildid: Avoid wraparound when aligning ELF note sizes
Date: Sat, 5 Dec 2026 13:43:46 +0000 (UTC) [thread overview]
Message-ID: <d80fbbfc884f95ac93a7aee04ea64285d1d2389eae710581b100f0445960c379@mail.kernel.org> (raw)
In-Reply-To: <20261205131119.105160-2-blum@kernel.org>
[-- Attachment #1: Type: text/plain, Size: 2140 bytes --]
> lib/buildid: Avoid wraparound when aligning ELF note sizes
TL;DR: Commit message only: it claims note sizes 0xfffffffd-0xffffffff
wrapping to 0 is a problem, but the review finds no real behaviour change, and
asks what this u64 patch actually fixes.
> lib/buildid: Avoid wraparound when aligning ELF note sizes
>
> For u32 note sizes, ALIGN() wraps the values 0xfffffffd through
> 0xffffffff to 0 before check_add_overflow() runs. Parsing can then
> continue as if the affected size were 0.
> Use u64 for name_sz and desc_sz to avoid alignment wraparound, allowing
> check_add_overflow() to reject these malformed notes early.
>
> Signed-off-by: Thorsten Blum <blum@kernel.org>
> diff --git a/lib/buildid.c b/lib/buildid.c
> --- a/lib/buildid.c
> +++ b/lib/buildid.c
> @@ -161,7 +161,8 @@ static int parse_build_id(struct freader *r, unsigned char *build_id, __u32 *siz
> {
> const char note_name[] = "GNU";
> const size_t note_name_sz = sizeof(note_name);
> - u32 build_id_off, new_off, note_end, name_sz, desc_sz;
> + u32 build_id_off, new_off, note_end;
> + u64 name_sz, desc_sz;
> const Elf32_Nhdr *nhdr;
> const char *data;
An earlier version of this patch drew a review comment that only
0xfffffffd, 0xfffffffe and 0xffffffff wrap, that they behave like size 0,
and that size 0 is valid in n_namesz and n_descsz and gives the same
new_off. The thread is at:
https://lore.kernel.org/all/DN8ARGULOD13.2ES34FRWS1M2B@gmail.com/
The commit message still says "Parsing can then continue as if the affected
size were 0." Is that an actual problem?
In parse_build_id(), new_off still advances by at least
sizeof(Elf32_Nhdr) and stays within note_end for such a note. A note with
those sizes can never match, since a match needs name_sz == note_name_sz
and desc_sz <= BUILD_ID_SIZE_MAX.
Could the commit message explain what behavior changes with this patch,
given that analysis?
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/47525085165
next prev parent reply other threads:[~2026-12-05 13:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 13:11 Thorsten Blum
2026-12-05 13:43 ` bot+bpf-ci [this message]
2026-12-05 16:34 ` Alexei Starovoitov
2026-12-05 17:14 ` Thorsten Blum
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=d80fbbfc884f95ac93a7aee04ea64285d1d2389eae710581b100f0445960c379@mail.kernel.org \
--to=bot+bpf-ci@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=blum@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=ihor.solodrai@linux.dev \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@kernel.org \
--cc=martin.lau@linux.dev \
--cc=mason@kernel.org \
--cc=memxor@gmail.com \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/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®