Linux Trace Kernel
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Steven Rostedt" <rostedt@goodmis.org>,
	"Linux Trace Kernel" <linux-trace-kernel@vger.kernel.org>
Subject: Re: [PATCH v4] tracing/probes: Zero out faulted dereferenced fields
Date: Fri, 20 Nov 2026 19:52:53 +0000	[thread overview]
Message-ID: <sashiko-outbox-225971@kernel.org> (raw)
In-Reply-To: <20261120143002.18b364b3@gandalf.local.home>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] tracing/probes: process_fetch_insn_bottom() string array loop
  checks val
--

commit 1bda61677a4b06fd01938014840ab606ebd55bfe
Author: Steven Rostedt <rostedt@goodmis.org>

tracing/probes: Zero out faulted dereferenced fields

This commit wraps probe_mem_read() and probe_mem_read_user() to zero out
the destination on failure, and continues through stage 2 of
process_fetch_insn_bottom() with a zero value rather than returning early
when a pointer dereference is NULL or faults.

> diff --git a/kernel/trace/trace_probe_tmpl.h b/kernel/trace/trace_probe_tmpl.h
> index 8db12f758fdae..4eb0ebe5767cd 100644
> --- a/kernel/trace/trace_probe_tmpl.h
> +++ b/kernel/trace/trace_probe_tmpl.h

[ ... ]

> @@ -225,11 +263,15 @@ process_fetch_insn_bottom(struct fetch_insn *code, unsigned long val,
>  			if (s3->op != FETCH_OP_ST_STRING &&
>  			    s3->op != FETCH_OP_ST_USTRING) {
>  				dest += s3->size;
> -				val += s3->size;
> +				/* Only update a non NULL val */
> +				if (val)
> +					val += s3->size;
>  				goto stage3;
>  			}
>  			code--;
> -			val = lval + sizeof(char *);
> +			/* Only update a non NULL val */
> +			if (val)
> +				val = lval + sizeof(char *);

[Severity: Medium]
Should this check if (lval) instead of if (val) when advancing through a
string pointer array?

For FETCH_OP_ST_STRING and FETCH_OP_ST_USTRING arrays, stage 2 saves the
current array slot address in lval and dereferences that slot into val.
If the array pointer lval is valid but element i is NULL (or reading it
faulted), val is 0 while lval is non-zero.  Checking if (val) leaves val
as 0 instead of advancing to lval + sizeof(char *), so jumping back to
stage2 overwrites lval with 0 and causes all remaining string elements in
the array to be skipped and recorded as faulted.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261120143002.18b364b3@gandalf.local.home?part=1

  reply	other threads:[~2026-11-20 19:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 19:30 [PATCH v4] tracing/probes: Zero out faulted dereferenced fields Steven Rostedt
2026-11-20 19:52 ` sashiko-bot [this message]
2026-11-20 20:10   ` Steven Rostedt

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=sashiko-outbox-225971@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.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