Hello Jiayuan Chen,
Commit 7b2fa44de5e7 ("selftest/bpf/benchs: Add benchmark for sockmap usage") from Apr 7, 2025 (linux-next), leads to the following Smatch static checker warning:
tools/testing/selftests/bpf/benchs/bench_sockmap.c:129 bench_sockmap_prog_destroy() error: buffer overflow 'ctx.fds' 5 <= 19
tools/testing/selftests/bpf/benchs/bench_sockmap.c 123 static void bench_sockmap_prog_destroy(void) 124 { 125 int i; 126 127 for (i = 0; i < sizeof(ctx.fds); i++) { ^^^^^^^^^^^^^^^ This should be ARRAY_SIZE(ctx.fds) otherwise it's a buffer overflow.
128 if (ctx.fds[0] > 0) ^^^^^^^^^^ Instead of .fds[0] it should be .fds[i], right?
--> 129 close(ctx.fds[i]); 130 } 131 132 bench_sockmap_prog__destroy(ctx.skel); 133 }
regards, dan carpenter