All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libbpf: fix missing minus sign in btf_dump struct zero-check
@ 2026-11-02  8:51 Gu Bin
  2026-11-02  9:25 ` bot+bpf-ci
  2026-11-02 13:16 ` [PATCH v2] libbpf: Fix ENODATA comparison and unbounded zero-scan in btf_dump Gu Bin
  0 siblings, 2 replies; 9+ messages in thread
From: Gu Bin @ 2026-11-02  8:51 UTC (permalink / raw)
  To: bpf; +Cc: ast, daniel, andrii, alan.maguire

btf_dump_type_data_check_zero() returns -ENODATA when a datum is all
zero (nothing to dump). In the BTF_KIND_STRUCT case the per-member
result is compared with ENODATA (no minus sign), unlike every other
branch which uses -ENODATA. The function only ever returns -ENODATA,
so the comparison `err != ENODATA` is always true and the loop bails
out on the first all-zero member: a struct that still has non-zero
members is reported as empty and skipped by the dumper.

Use -ENODATA so non-zero members are handled correctly.

Fixes: 920d16af9b42 ("libbpf: BTF dumper support for typed data")
Signed-off-by: Gu Bin <gubin@cmss.chinamobile.com>
---
 tools/lib/bpf/btf_dump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/lib/bpf/btf_dump.c b/tools/lib/bpf/btf_dump.c
index 7dedd3975c39..ea9a34db4c00 100644
--- a/tools/lib/bpf/btf_dump.c
+++ b/tools/lib/bpf/btf_dump.c
@@ -2567,7 +2567,7 @@ static int btf_dump_type_data_check_zero(struct btf_dump *d,
 			bit_sz = btf_member_bitfield_size(t, i);
 			err = btf_dump_type_data_check_zero(d, mtype, m->type, data + moffset / 8,
 							    moffset % 8, bit_sz);
-			if (err != ENODATA)
+			if (err != -ENODATA)
 				return err;
 		}
 		return -ENODATA;
-- 
2.55.0.windows.3




^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-11-03  4:30 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-02  8:51 [PATCH] libbpf: fix missing minus sign in btf_dump struct zero-check Gu Bin
2026-11-02  9:25 ` bot+bpf-ci
2026-11-02 13:16 ` [PATCH v2] libbpf: Fix ENODATA comparison and unbounded zero-scan in btf_dump Gu Bin
2026-11-02 16:47   ` Alexei Starovoitov
2026-11-03  3:26   ` [PATCH bpf-next v3 0/2] Fix OOB read in BTF dumper zero-scan Gu Bin
2026-11-03  3:26     ` [PATCH bpf-next v3 1/2] libbpf: " Gu Bin
2026-11-03  3:26     ` [PATCH bpf-next v3 2/2] selftests/bpf: Add overflow test for BTF dump zero-scan Gu Bin
2026-11-03  3:32       ` sashiko-bot
2026-11-03  4:30       ` Alexei Starovoitov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.