Linux Trace Kernel
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: sashiko-bot@kernel.org
Cc: sashiko-reviews@lists.linux.dev,
	"Dominik Maier" <dmnk@google.com>,
	linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v3] tracing: Bound synthetic event dynamic string and stack stores to reserved size
Date: Fri, 4 Dec 2026 15:32:32 -0500	[thread overview]
Message-ID: <20261204153232.1ffaf1df@gandalf.local.home> (raw)
In-Reply-To: <sashiko-outbox-246990@kernel.org>

On Thu, 03 Dec 2026 02:24:33 +0000
sashiko-bot@kernel.org wrote:

> > @@ -1955,16 +2005,23 @@ int synth_event_trace_array(struct trace_event_file *file, u64 *vals,
> >  		goto out;
> >  	}
> >  
> > +	maxlen = data_size;
> > +	rem_strings = state.event->n_dynamic_strings;
> >  	data_size = 0;
> >  
> >  	for (i = 0, n_u64 = 0; i < state.event->n_fields; i++) {
> >  		if (state.event->fields[i]->is_string) {
> >  			char *str_val = (char *)(long)vals[i];
> > +			unsigned int str_max = 0;
> > +
> > +			if (state.event->fields[i]->is_dynamic)
> > +				str_max = synth_dyn_budget(maxlen, --rem_strings);
> >  
> >  			len = trace_string(state.entry, state.event, str_val,
> >  					   state.event->fields[i]->is_dynamic,
> > -					   data_size, &n_u64);
> > +					   data_size, str_max, &n_u64);
> >  			data_size += len; /* only dynamic string increments */
> > +			maxlen -= len;
> >  		} else {
> >  			struct synth_field *field = state.event->fields[i];
> >  			u64 val = vals[i];  
> 
> [Severity: Medium]
> Can an is_stack field in synth_event_trace_array() or synth_event_trace()
> corrupt state.entry->fields[n_u64].as_dynamic and trigger an out-of-bounds
> read?
> 
> Skipping is_stack fields in the reservation loop reserves zero dynamic
> bytes for them, but the field-writing loop below has no is_stack branch
> and falls into the scalar switch, where field->size == sizeof(u64) writes
> vals[i] into state.entry->fields[n_u64].as_u64.  That overwrites
> as_dynamic.offset and as_dynamic.len with raw bits from vals[i], so
> print_synth_event() and hist_field_stack() read past the end of the ring
> buffer entry.
> 
> Should synth_event_trace_array() and synth_event_trace() either reserve
> and store stack fields via synth_stack_size() and trace_stack(), or
> reject events with is_stack fields with -ENOTSUPP like
> synth_event_trace_start()?

Can you address this as well?

-- Steve

  reply	other threads:[~2026-12-04 20:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  2:04 [PATCH v3] tracing: Bound synthetic event dynamic string and stack stores to reserved size Dominik Maier
2026-12-03  2:24 ` sashiko-bot
2026-12-04 20:32   ` Steven Rostedt [this message]
2026-12-04 20:32 ` 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=20261204153232.1ffaf1df@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=dmnk@google.com \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=sashiko-bot@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