Re: [PATCH] libbpf: Limit bitfield dump reads to checked bytes
From: bot+bpf-ci
Date: Tue Jul 07 2026 - 23:49:53 EST
> diff --git a/tools/lib/bpf/btf_dump.c b/tools/lib/bpf/btf_dump.c
> index 53c6624161d7..d82e8e425203 100644
> --- a/tools/lib/bpf/btf_dump.c
> +++ b/tools/lib/bpf/btf_dump.c
[ ... ]
> @@ -1784,13 +1788,13 @@ static int btf_dump_get_bitfield_value(struct btf_dump *d,
> * stored in num, then we left/right shift num to eliminate irrelevant bits.
> */
> #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
> - for (i = t->size - 1; i >= 0; i--)
> + for (i = nr_bytes - 1; i >= 0; i--)
> num = num * 256 + bytes[i];
> - nr_copy_bits = bit_sz + bits_offset;
> + nr_copy_bits = bit_sz ? bit_sz + bits_offset : nr_bytes * 8;
> #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
> - for (i = 0; i < t->size; i++)
> + for (i = 0; i < nr_bytes; i++)
> num = num * 256 + bytes[i];
> - nr_copy_bits = t->size * 8 - bits_offset;
> + nr_copy_bits = nr_bytes * 8 - bits_offset;
Varun R Mallya asked in v2 for examples that can break the older
implementation, preferably with an ASAN report to justify the change.
Could you provide a test case or ASAN report demonstrating the issue? Without
demonstrable evidence of the OOB read, it's hard to evaluate whether this
change is necessary.
The previous review is at:
https://lore.kernel.org/bpf/akugPNylTrOa_bNn@computer
---
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/28914496440