[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260205135842.20517-3-seokwoo.chung130@gmail.com>
Date: Thu, 5 Feb 2026 08:58:40 -0500
From: "Seokwoo Chung (Ryan)" <seokwoo.chung130@...il.com>
To: mhiramat@...nel.org
Cc: rostedt@...dmis.org,
corbet@....net,
shuah@...nel.org,
mathieu.desnoyers@...icios.com,
linux-kernel@...r.kernel.org,
linux-trace-kernel@...r.kernel.org,
linux-doc@...r.kernel.org,
linux-kselftest@...r.kernel.org,
"Seokwoo Chung (Ryan)" <seokwoo.chung130@...il.com>
Subject: [PATCH v6 2/4] fprobe: Support comma-separated filters in register_fprobe()
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".
Signed-off-by: Seokwoo Chung (Ryan) <seokwoo.chung130@...il.com>
---
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
Powered by blists - more mailing lists