Linux Kernel Selftest development
 help / color / mirror / Atom feed
* [bug report] selftest/bpf/benchs: Add benchmark for sockmap usage
@ 2025-09-05  8:29 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2025-09-05  8:29 UTC (permalink / raw)
  To: Jiayuan Chen; +Cc: bpf, linux-kselftest

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

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

only message in thread, other threads:[~2025-09-05  8:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-05  8:29 [bug report] selftest/bpf/benchs: Add benchmark for sockmap usage Dan Carpenter

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