Re: [PATCH bpf-next v1 13/14] selftests/bpf: Fix out-of-bounds array access bugs reported by ASAN
From: Eduard Zingerman
Date: Thu Feb 12 2026 - 20:11:50 EST
On Wed, 2026-02-11 at 17:13 -0800, Ihor Solodrai wrote:
> - kmem_cache_iter: remove unnecessary debug output
> - lwt_seg6local: change the type of foobar to char[]
> - the sizeof(foobar) returned the pointer size and not a string
> length as intended
> - verifier_log: increase prog_name buffer size in verif_log_subtest()
> - compiler has a conservative estimate of fixed_log_sz value, making
> ASAN complain on snprint() call
>
> Signed-off-by: Ihor Solodrai <ihor.solodrai@xxxxxxxxx>
> ---
Acked-by: Eduard Zingerman <eddyz87@xxxxxxxxx>
[...]
> diff --git a/tools/testing/selftests/bpf/prog_tests/kmem_cache_iter.c
> b/tools/testing/selftests/bpf/prog_tests/kmem_cache_iter.c
> index 6e35e13c2022..399fe9103f83 100644
> --- a/tools/testing/selftests/bpf/prog_tests/kmem_cache_iter.c
> +++ b/tools/testing/selftests/bpf/prog_tests/kmem_cache_iter.c
> @@ -104,11 +104,8 @@ void test_kmem_cache_iter(void)
> if (!ASSERT_GE(iter_fd, 0, "iter_create"))
> goto destroy;
>
> - memset(buf, 0, sizeof(buf));
> - while (read(iter_fd, buf, sizeof(buf)) > 0) {
> - /* Read out all contents */
> - printf("%s", buf);
> - }
> + while (read(iter_fd, buf, sizeof(buf)) > 0)
> + ; /* Read out all contents */
Nit:
- while (read(iter_fd, buf, sizeof(buf)) > 0) {
+ while (read(iter_fd, buf, sizeof(buf) - 1) > 0) {
And keep the log?
[...]