Re: [PATCH v6 2/4] fprobe: Support comma-separated filters in register_fprobe()
From: Google
Date: Mon Mar 23 2026 - 22:05:52 EST
On Thu, 5 Feb 2026 08:58:40 -0500
"Seokwoo Chung (Ryan)" <seokwoo.chung130@xxxxxxxxx> wrote:
> register_fprobe() passes its filter and notfilter strings directly to
> glob_match(), which only understands shell-style globs (*, ?, [...]).
> Comma-separated symbol lists such as "vfs_read,vfs_open" never match
> any symbol because no kernel symbol contains a comma.
>
> Add glob_match_comma_list() that splits the filter on commas and
> checks each entry individually with glob_match(). The existing
> single-pattern fast path is preserved (no commas means the loop
> executes exactly once).
>
> This is required by the comma-separated fprobe list syntax introduced
> in the preceding patch; without it, enabling a list-mode fprobe event
> fails with "Could not enable event".
OK, in this case, you should reorder patch this as the first one.
Please make this [1/4] and remove this requirement explanation paragraph.
The patch itself looks good to me.
Thank you,
>
> Signed-off-by: Seokwoo Chung (Ryan) <seokwoo.chung130@xxxxxxxxx>
> ---
> kernel/trace/fprobe.c | 30 ++++++++++++++++++++++++++++--
> 1 file changed, 28 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/trace/fprobe.c b/kernel/trace/fprobe.c
> index 1188eefef07c..2acd24b80d04 100644
> --- a/kernel/trace/fprobe.c
> +++ b/kernel/trace/fprobe.c
> @@ -672,12 +672,38 @@ struct filter_match_data {
> struct module **mods;
> };
>
> +/*
> + * Check if @name matches any comma-separated glob pattern in @list.
> + * If @list contains no commas, this is equivalent to glob_match().
> + */
> +static bool glob_match_comma_list(const char *list, const char *name)
> +{
> + const char *cur = list;
> +
> + while (*cur) {
> + const char *sep = strchr(cur, ',');
> + int len = sep ? sep - cur : strlen(cur);
> + char pat[KSYM_NAME_LEN];
> +
> + if (len > 0 && len < KSYM_NAME_LEN) {
> + memcpy(pat, cur, len);
> + pat[len] = '\0';
> + if (glob_match(pat, name))
> + return true;
> + }
> + if (!sep)
> + break;
> + cur = sep + 1;
> + }
> + return false;
> +}
> +
> static int filter_match_callback(void *data, const char *name, unsigned long addr)
> {
> struct filter_match_data *match = data;
>
> - if (!glob_match(match->filter, name) ||
> - (match->notfilter && glob_match(match->notfilter, name)))
> + if (!glob_match_comma_list(match->filter, name) ||
> + (match->notfilter && glob_match_comma_list(match->notfilter, name)))
> return 0;
>
> if (!ftrace_location(addr))
> --
> 2.43.0
>
>
--
Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>