From: Thorsten Blum <blum@kernel.org>
To: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>,
Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
Jiri Olsa <jolsa@kernel.org>,
Emil Tsalapatis <emil@etsalapatis.com>,
Ihor Solodrai <ihor.solodrai@linux.dev>,
Andrew Morton <akpm@linux-foundation.org>,
Shakeel Butt <shakeel.butt@linux.dev>
Cc: Thorsten Blum <blum@kernel.org>,
bpf@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] lib/buildid: Prevent overflow when aligning ELF note sizes
Date: Mon, 23 Nov 2026 15:25:10 +0100 [thread overview]
Message-ID: <20261123142510.51241-2-blum@kernel.org> (raw)
Commit de3ec364c3c3 ("lib/buildid: add single folio-based file reader
abstraction") changed name_sz and desc_sz from u64 to u32. As a result,
ALIGN() could wrap malformed sizes near U32_MAX to 0, which would allow
such values to bypass the overflow checks and parsing to continue with
an incorrect note offset.
Restore u64 for name_sz and desc_sz to prevent alignment overflow. The
existing check_add_overflow() calls then reject sums that do not fit in
the u32 offset.
Fixes: de3ec364c3c3 ("lib/buildid: add single folio-based file reader abstraction")
Signed-off-by: Thorsten Blum <blum@kernel.org>
---
lib/buildid.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/buildid.c b/lib/buildid.c
index 995a327f46ae..767243f424d6 100644
--- 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;
reply other threads:[~2026-11-23 14:25 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261123142510.51241-2-blum@kernel.org \
--to=blum@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=andrii@kernel.org \
--cc=ast@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@linux.dev \
--cc=memxor@gmail.com \
--cc=shakeel.butt@linux.dev \
--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®