]> www.infradead.org Git - users/jedix/linux-maple.git/commit
perf bpf-filter: Fix a parsing error with comma
authorNamhyung Kim <namhyung@kernel.org>
Fri, 7 Mar 2025 22:09:21 +0000 (14:09 -0800)
committerNamhyung Kim <namhyung@kernel.org>
Tue, 25 Mar 2025 00:29:58 +0000 (17:29 -0700)
commit35d13f841a3d8159ef20d5e32a9ed3faa27875bc
tree7e74ba189ac9aae61c1a6d51ce96ca776feacec3
parent9daa05c84a27629577287897af4fcf19c238796a
perf bpf-filter: Fix a parsing error with comma

The previous change to support cgroup filters introduced a bug that
pathname can include commas.  It confused the lexer to treat an item and
the trailing comma as a single token.  And it resulted in a parse error:

  $ sudo perf record -e cycles:P --filter 'period > 0, ip > 64' -- true
  perf_bpf_filter: Error: Unexpected item: 0,
  perf_bpf_filter: syntax error, unexpected BFT_ERROR, expecting BFT_NUM

   Usage: perf record [<options>] [<command>]
      or: perf record [<options>] -- <command> [<options>]

          --filter <filter>
                            event filter

It should get "0" and "," separately.

An easiest fix would be to remove "," from the possible pathname
characters.  As it's for cgroup names, probably ok to assume it won't
have commas in the pathname.

I found that the existing BPF filtering test didn't have any complex
filter condition with commas.  Let's update the group filter test which
is supposed to test filter combinations like this.

Link: https://lore.kernel.org/r/20250307220922.434319-1-namhyung@kernel.org
Fixes: 91e88437d5156b20 ("perf bpf-filter: Support filtering on cgroups")
Reported-by: Sally Shi <sshii@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/tests/shell/record_bpf_filter.sh
tools/perf/util/bpf-filter.l