All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
Cc: linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH RFC 7/7] tracing: Parse filter from event string
Date: Thu, 13 Aug 2026 14:22:58 +0000	[thread overview]
Message-ID: <20260813142258.D2D4F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260813-tracing-cli-event-filter-v1-7-57c4e8029c86@linutronix.de>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The `:mod:` suffix parsing using `strstr` is broken by the introduction of filter expressions, which can legitimately contain `:mod:` within string literals.
- [Medium] Unintended userspace ABI change for the debugfs `set_event` interface by exposing event string filter parsing.
--

--- Patch [7]: [PATCH RFC 7/7] tracing: Parse filter from event string ---
commit d99b1133b250a61ac85f36416d5a9f5e175d37f9
Author: Thomas Weißschuh <thomas.weissschuh@linutronix.de>

tracing: Parse filter from event string

This commit makes it possible to specify a trace event filter from the kernel
command line by extracting it from the event string.

> diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
> index c24929d003dd6..d4c46b24c3829 100644
> --- a/kernel/trace/trace_events.c
> +++ b/kernel/trace/trace_events.c
> @@ -1426,10 +1426,12 @@ static int __ftrace_set_clr_event(struct trace_array *tr, const char *match,
>  }
>  
>  VISIBLE_IF_KUNIT void
> -ftrace_parse_event_string(char *buf, char **match, char **sub, char **event, char **mod)
> +ftrace_parse_event_string(char *buf, char **match, char **sub, char **event, char **mod,
> +			  char **filter)
>  {
>  	*event = NULL;
>  	*sub = NULL;
> +	*filter = NULL;
>  
>  	/* Modules events can be appended with :mod:<module> */
>  	*mod = strstr(buf, ":mod:");

[Severity: High]
Does this code incorrectly match the module string inside the filter string?

If a filter expression is provided that legitimately contains the literal
string ":mod:" (for example, comm == "my:mod:app"), strstr() will match it
here before the buffer is tokenized. 

This could truncate the filter and falsely extract a module name, causing
event enablement to fail.

[ ... ]

> @@ -1471,7 +1476,7 @@ EXPORT_SYMBOL_IF_KUNIT(ftrace_parse_event_string);
>  
>  int ftrace_set_clr_event(struct trace_array *tr, const char *_buf, int set)
>  {
> -	char *event, *sub, *match, *mod;
> +	char *event, *sub, *match, *mod, *filter;
>  
>  	if (!tr)
>  		return -ENOENT;
> @@ -1480,9 +1485,9 @@ int ftrace_set_clr_event(struct trace_array *tr, const char *_buf, int set)
>  	if (!buf)
>  		return -ENOMEM;
>  
> -	ftrace_parse_event_string(buf, &match, &sub, &event, &mod);
> +	ftrace_parse_event_string(buf, &match, &sub, &event, &mod, &filter);
>  
> -	return __ftrace_set_clr_event(tr, match, sub, event, set, mod, NULL);
> +	return __ftrace_set_clr_event(tr, match, sub, event, set, mod, filter);
>  }

[Severity: Medium]
Will this unintentionally alter the ABI for the set_event debugfs file?

Since ftrace_set_clr_event() is called by the debugfs set_event file write
handler, this change exposes the filter parsing to userspace writes. 

Writing strings with colons directly to set_event will now attempt to parse
them as filters, changing the expected ABI behavior and error semantics of
the interface. 

As mentioned in the patch notes, shouldn't this be limited to only apply to
the command line path?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260813-tracing-cli-event-filter-v1-0-57c4e8029c86@linutronix.de?part=7

  reply	other threads:[~2026-08-13 14:22 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-13 14:07 [PATCH RFC 0/7] tracing: Parse filter from event string Thomas Weißschuh
2026-08-13 14:07 ` [PATCH RFC 1/7] tracing: Restore :mod: trailer after parsing in ftrace_set_clr_event() Thomas Weißschuh
2026-08-13 14:07 ` [PATCH RFC 2/7] tracing: Remove duplicate declaration of ftrace_set_clr_event() Thomas Weißschuh
2026-08-13 14:07 ` [PATCH RFC 3/7] tracing: Stop modifying the input buffer in ftrace_set_clr_event() Thomas Weißschuh
2026-08-13 14:15   ` sashiko-bot
2026-08-13 14:38     ` Steven Rostedt
2026-08-13 14:40       ` Thomas Weißschuh
2026-08-13 14:45         ` Steven Rostedt
2026-08-13 14:07 ` [PATCH RFC 4/7] tracing: Split the event string parsing logic into a dedicated function Thomas Weißschuh
2026-08-13 14:07 ` [PATCH RFC 5/7] tracing: Add a test for ftrace_parse_event_string() Thomas Weißschuh
2026-08-13 14:14   ` sashiko-bot
2026-08-13 14:07 ` [PATCH RFC 6/7] tracing: Add a filter argument to __ftrace_set_clr_event() Thomas Weißschuh
2026-08-13 14:07 ` [PATCH RFC 7/7] tracing: Parse filter from event string Thomas Weißschuh
2026-08-13 14:22   ` sashiko-bot [this message]
2026-08-13 16:22   ` Masami Hiramatsu

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=20260813142258.D2D4F1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=thomas.weissschuh@linutronix.de \
    /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.