Re: [PATCH v4 06/15] tracing/filters: Fix quoted operand parsing in function event filter
From: Masami Hiramatsu (Google)
Date: Wed Nov 18 2026 - 19:38:30 EST
On Tue, 17 Nov 2026 19:14:21 -0500, Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
> On Thu, 29 Oct 2026 10:38:21 +0900
> "Masami Hiramatsu (Google)" <mhiramat@xxxxxxxxxx> wrote:
>
> > From: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>
> >
> > In parse_pred(), when parsing a quoted operand for function events (e.g.
> > ip == "schedule"):
> > 1. The loop 'for (i++; str[i]; i++)' breaks when str[i] matches the
> > closing quote, but 'i' is never incremented past the closing quote.
> > As a result, parse_pred() returns 'i' pointing at the closing quote,
> > causing the caller predicate_parse() to immediately re-parse the
> > closing quote as the start of the next token and fail with
> > FILT_ERR_TOO_MANY_PREDS.
> > 2. If the closing quote is missing (e.g. ip == "schedule), the loop stops
> > at the NUL terminator without reporting an error.
> > 3. The loop started with 'i++', which was intended to skip the opening
> > quote, but also unconditionally skipped the first character of unquoted
> > function operands.
>
> Can you show actual examples of setting filters that fail with the above
> issues. Something I can test and see that what was fixed, and that it was
> indeed fixed.
For this issue, we need to use "perf record" to reproduce it. It seems
that expected behavior [1], only perf can set filter to
ftrace:funtion event. From the tracefs, ftrace:function event does
not have filter .
/sys/kernel/tracing # ls events/ftrace/function/
format hist id
But perf (perf_event_open + ioctl(PERF_EVENT_IOC_SET_FILTER)) can
set the filter to ftrace:function event e.g.
perf record -e ftrace:function --filter 'ip == "schedule"' -a -- sleep 1
This should succeed, but it fails without this patch because parse_pred()
stops at the closing "(double quote).
failed to set filter "ip == "schedule"" on event ftrace:function: Operation not permitted
With this patch, the perf succeeds to run.
[1] commit 80765597bc58 ("tracing: Rewrite filter logic to be simpler and
faster")
-----
} else if (ftrace_event_is_function(call)) {
/*
* Perf does things different with function events.
* It only allows an "ip" field, and expects a string.
* But the string does not need to be surrounded by quotes.
* If it is a string, the assigned function as a nop,
* (perf doesn't use it) and grab everything.
*/
-----
Thanks,
>
> Thanks,
>
> -- Steve
>
--
Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>