From: sashiko-bot@kernel.org
Cc: bpf@vger.kernel.org
Subject: Re: [RFC PATCH 1/4] tools/tracing: Add fetcharg performance micro-benchmark
Date: Wed, 01 Jul 2026 13:53:41 +0000 [thread overview]
Message-ID: <20260701135342.3CFED1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <178291353202.1566898.1316084678106262789.stgit@devnote2>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Divide by zero in benchmark calculation causing a kernel panic
- [Medium] Buffer Overflow / User-Space Out-of-Bounds Write due to ignored `count` in `fetcharg_bench_read`
--
commit e30ac26f087c17e4a2160772405d441b6e416abd
Author: Masami Hiramatsu (Google) <mhiramat@kernel.org>
tools/tracing: Add fetcharg performance micro-benchmark
This commit adds a benchmark test module and a shell script to measure the
execution overhead of fetchargs across kprobe, fprobe, and eprobe
configurations.
> diff --git a/tools/tracing/benchmark/fetcharg_bench.c b/tools/tracing/benchmark/fetcharg_bench.c
> new file mode 100644
> index 0000000000000..af18183c1f5d5
> --- /dev/null
> +++ b/tools/tracing/benchmark/fetcharg_bench.c
[ ... ]
> +static ssize_t fetcharg_bench_read(struct file *file, char __user *user_buf,
> + size_t count, loff_t *ppos)
> +{
> + char buf[64];
> + int len;
> + u64 start, current_time;
> + u64 elapsed;
> + u64 loops_per_sec;
[ ... ]
> + start = ktime_get_ns();
> + for (i = 0; i < BENCH_ITERATIONS; i++)
> + dummy += bench_func_ptr(a, b, c);
> + current_time = ktime_get_ns();
> +
> + elapsed = current_time - start;
> + loops_per_sec = ((u64)BENCH_ITERATIONS * NSEC_PER_SEC) / elapsed;
[Severity: High]
Could this result in a divide by zero? If the system lacks high-resolution
timers or if the loop completes within the same timer tick, elapsed could
evaluate to 0 and cause a kernel panic.
> +
> + len = snprintf(buf, sizeof(buf), "%llu\n", loops_per_sec);
> + if (len < 0)
> + return len;
> +
> + if (copy_to_user(user_buf, buf, len))
[Severity: Medium]
Does this code ignore the user-provided count parameter?
If a user program calls read() on the debugfs file with a count parameter
smaller than the formatted string length len, it appears we could write beyond
the bounds of the user-provided buffer by copying len bytes instead of
honoring the count.
--
Sashiko AI review · https://sashiko.dev/#/patchset/178291352217.1566898.14481561093843379745.stgit@devnote2?part=1
next prev parent reply other threads:[~2026-07-01 13:53 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-01 13:45 [RFC PATCH 0/4] tracing/probes: Optimize fetcharg with BPF Masami Hiramatsu (Google)
2026-07-01 13:45 ` [RFC PATCH 1/4] tools/tracing: Add fetcharg performance micro-benchmark Masami Hiramatsu (Google)
2026-07-01 13:53 ` sashiko-bot [this message]
2026-07-01 13:45 ` [RFC PATCH 2/4] tracing/probes: Compile all fetchargs into a single BPF program per event Masami Hiramatsu (Google)
2026-07-01 14:06 ` sashiko-bot
2026-07-01 18:41 ` Alexei Starovoitov
2026-07-01 18:47 ` Steven Rostedt
2026-07-01 18:53 ` Alexei Starovoitov
2026-07-01 22:40 ` Masami Hiramatsu
2026-07-02 0:01 ` Alexei Starovoitov
2026-07-02 1:01 ` Masami Hiramatsu
2026-07-02 14:04 ` Steven Rostedt
2026-07-01 13:45 ` [RFC PATCH 3/4] tracing: Add disable_bpf trace option to ignore eBPF for fetchargs Masami Hiramatsu (Google)
2026-07-01 14:02 ` sashiko-bot
2026-07-01 13:46 ` [RFC PATCH 4/4] selftests/ftrace: Add a test for eBPF compiled fetchargs Masami Hiramatsu (Google)
2026-07-01 13:53 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260701135342.3CFED1F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox