All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Aaron Tomlin" <atomlin@atomlin.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v2 perf-tools-next 4/6] perf trace beauty: Validate payload size in augmented timespec beautifier
Date: Mon, 07 Sep 2026 02:05:15 +0000	[thread overview]
Message-ID: <20260907020516.2678C1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260907015140.363076-5-atomlin@atomlin.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Validation logic relies on the host's native `struct timespec` layout instead of dynamically querying the trace environment, breaking cross-platform analysis.
- [Medium] Validation relies on an uninitialized/stale field from the BPF tracer, silently breaking timespec formatting.
--

commit 8e3c4b6ee60070e35799a1584520842d1e0f8b14
Author: Aaron Tomlin <atomlin@atomlin.com>

perf trace beauty: Validate payload size in augmented timespec beautifier

This commit adds bounds checking to the augmented timespec beautifier in perf 
trace to prevent reading past the end of the payload buffer for malformed or 
truncated perf.data records.

> diff --git a/tools/perf/trace/beauty/timespec.c b/tools/perf/trace/beauty/timespec.c
> index b14ab72a2738e..fad503bd953a6 100644
> --- a/tools/perf/trace/beauty/timespec.c
> +++ b/tools/perf/trace/beauty/timespec.c
> @@ -7,15 +7,28 @@
>  
>  static size_t syscall_arg__scnprintf_augmented_timespec(struct syscall_arg *arg, char *bf, size_t size)
>  {
> -	struct timespec *ts = (struct timespec *)arg->augmented.args->value;
> +	struct augmented_arg *augmented_arg = arg->augmented.args;
> +	struct timespec *ts;
>  
> +	if (arg->augmented.size < (int)sizeof(*augmented_arg))
> +		return 0;
> +
> +	if (augmented_arg->size < (int)sizeof(*ts) ||
> +	    augmented_arg->size > arg->augmented.size - (int)sizeof(*augmented_arg))
> +		return 0;

[Severity: Medium]
Does this validation break cross-architecture trace analysis? The check
relies strictly on the host's sizeof(*ts), which evaluates to 16 on a
64-bit host. If a perf.data file recorded on a 32-bit architecture is
analyzed here, wouldn't the tracee's valid, smaller payload be incorrectly
rejected by this bounds check?

[Severity: Medium]
Can this bounds check fail randomly due to uninitialized data from the
eBPF tracer? Looking at the eBPF side in sys_enter_clock_nanosleep:

tools/perf/util/bpf_skel/augmented_raw_syscalls.bpf.c:sys_enter_clock_nanosleep() {
    ...
    bpf_probe_read_user(&augmented_args->arg.value, size, rqtp_arg);
    return augmented__output(args, augmented_args, len + size);
}

The eBPF tracer does not appear to initialize augmented_args->arg.size.
Since the augmented_args_tmp per-CPU array is reused across tracepoints,
if a prior syscall (like open) set the size to a path length, wouldn't
the new check here read that stale size and reject valid payloads?

> +
> +	ts = (struct timespec *)augmented_arg->value;
>  	return scnprintf(bf, size, "{ .tv_sec: %" PRIu64 ", .tv_nsec: %" PRIu64 " }", ts->tv_sec, ts->tv_nsec);
>  }

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260907015140.363076-1-atomlin@atomlin.com?part=4

  reply	other threads:[~2026-09-07  2:05 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-07  1:51 [PATCH v2 perf-tools-next 0/6] perf trace: Validate payload bounds across augmented argument beautifiers Aaron Tomlin
2026-09-07  1:51 ` [PATCH v2 perf-tools-next 1/6] perf trace: Add upper bound checks for augmented BTF struct printing Aaron Tomlin
2026-09-07  2:02   ` sashiko-bot
2026-09-07  1:51 ` [PATCH v2 perf-tools-next 2/6] perf trace: Validate payload bounds in augmented string beautifier Aaron Tomlin
2026-09-07  2:06   ` sashiko-bot
2026-09-07  1:51 ` [PATCH v2 perf-tools-next 3/6] perf trace: Validate payload bounds in augmented buffer beautifier Aaron Tomlin
2026-09-07  2:07   ` sashiko-bot
2026-09-07  1:51 ` [PATCH v2 perf-tools-next 4/6] perf trace beauty: Validate payload size in augmented timespec beautifier Aaron Tomlin
2026-09-07  2:05   ` sashiko-bot [this message]
2026-09-07  1:51 ` [PATCH v2 perf-tools-next 5/6] perf trace beauty: Validate payload size in augmented sockaddr beautifier Aaron Tomlin
2026-09-07  2:03   ` sashiko-bot
2026-09-07  1:51 ` [PATCH v2 perf-tools-next 6/6] perf trace beauty: Validate payload size in augmented perf_event_open beautifier Aaron Tomlin
2026-09-07  2:06   ` sashiko-bot
2026-09-19  0:30 ` [PATCH v2 perf-tools-next 0/6] perf trace: Validate payload bounds across augmented argument beautifiers Aaron Tomlin

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=20260907020516.2678C1F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=atomlin@atomlin.com \
    --cc=linux-perf-users@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.