BPF List
 help / color / mirror / Atom feed
* [PATCH] lib/buildid: Prevent overflow when aligning ELF note sizes
@ 2026-11-23 14:25 Thorsten Blum
  0 siblings, 0 replies; only message in thread
From: Thorsten Blum @ 2026-11-23 14:25 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Eduard Zingerman, Kumar Kartikeya Dwivedi, Martin KaFai Lau,
	Song Liu, Yonghong Song, Jiri Olsa, Emil Tsalapatis,
	Ihor Solodrai, Andrew Morton, Shakeel Butt
  Cc: Thorsten Blum, bpf, linux-kernel

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;
 

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-23 14:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 14:25 [PATCH] lib/buildid: Prevent overflow when aligning ELF note sizes Thorsten Blum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox