mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Brian Norris <briannorris@chromium.org>
Subject: [for-linus][PATCH 26/32] tracing: Properly match strings that start with numbers
Date: Fri, 20 Nov 2026 12:39:18 -0500	[thread overview]
Message-ID: <20261120174118.891370080@kernel.org> (raw)
In-Reply-To: <20261120173852.687189370@kernel.org>

From: Brian Norris <briannorris@chromium.org>

As an optimization, set_ftrace_filter supports writing indices (numbers)
instead of function names. This support was added to the generic glob
(fake regex) function, which breaks the ability to filter string
patterns that start with a number. For example, PCI device names tend to
look like '0001:01:00.0', and a reasonable filter might be:

  echo 'name ~ "0001:*"' > /sys/kernel/tracing/events/rpm/rpm_resume/filter

Move the MATCH_INDEX code out to the only place it actually was intended
to work -- ftrace match_records(), with a 'func' and no 'mod'.

As a side effect, this also fixes :mod:<module> function filtering for
modules whose names start with a digit.

Link: https://patch.msgid.link/20261116182710.1.Ic0625a2bd2e6f8960c0f75e5d15f14f3c84d1d38@changeid
Fixes: f79b3f338564 ("ftrace: Allow enabling of filters via index of available_filter_functions")
Signed-off-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/ftrace.c              | 3 ++-
 kernel/trace/trace.h               | 1 -
 kernel/trace/trace_events_filter.c | 5 -----
 3 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index c7d74b33d36d..6654da9d1bbf 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -5029,7 +5029,8 @@ match_records(struct ftrace_hash *hash, char *func, int len, char *mod)
 	if (unlikely(ftrace_disabled))
 		return 0;
 
-	if (func_g.type == MATCH_INDEX)
+	if (func_g.type == MATCH_FULL && !mod &&
+	    func_g.search && isdigit(func_g.search[0]))
 		return add_rec_by_index(hash, &func_g, clear_filter);
 
 	do_for_each_ftrace_rec(pg, rec) {
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 6b695a7f42c8..1fec567e789e 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -1807,7 +1807,6 @@ enum regex_type {
 	MATCH_MIDDLE_ONLY,
 	MATCH_END_ONLY,
 	MATCH_GLOB,
-	MATCH_INDEX,
 };
 
 struct regex {
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index a1c298210059..6704ef3d9520 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -1152,9 +1152,6 @@ enum regex_type filter_parse_regex(char *buff, int len, char **search, int *not)
 
 	*search = buff;
 
-	if (isdigit(buff[0]))
-		return MATCH_INDEX;
-
 	for (i = 0; i < len; i++) {
 		if (buff[i] == '*') {
 			if (!i) {
@@ -1192,8 +1189,6 @@ static void filter_build_regex(struct filter_pred *pred)
 	}
 
 	switch (type) {
-	/* MATCH_INDEX should not happen, but if it does, match full */
-	case MATCH_INDEX:
 	case MATCH_FULL:
 		r->match = regex_match_full;
 		break;
-- 
2.53.0

  parent reply	other threads:[~2026-11-20 17:41 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 17:38 Steven Rostedt
2026-11-20 17:38 ` [for-linus][PATCH 01/32] ring-buffer: Do not WARN when trace_rb_cpu_prepare() fails to allocate Steven Rostedt
2026-11-20 17:38 ` [for-linus][PATCH 02/32] tracing: Keep copying markers when one instance is stopped Steven Rostedt
2026-11-20 17:38 ` [for-linus][PATCH 03/32] tracing: Restrict perf filters that read kernel strings Steven Rostedt
2026-11-20 17:38 ` [for-linus][PATCH 04/32] tracing/filters: Treat zero-length dynamic strings as empty Steven Rostedt
2026-11-20 17:38 ` [for-linus][PATCH 05/32] tracing: Define common event fields before enabling boot events Steven Rostedt
2026-11-20 17:38 ` [for-linus][PATCH 06/32] tracing: Drop the synthetic event ref when clearing hist triggers Steven Rostedt
2026-11-20 17:38 ` [for-linus][PATCH 07/32] tracing: Avoid undefined shifts for zero histogram map size Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 08/32] tracing/filters: Fix MATCH_END_ONLY regex matching for fixed-size strings Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 09/32] tracing/filters: Handle out-of-range CPU for OP_NE in cpumask comparison Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 10/32] tracing/filters: Check for missing operand after operator in parse_pred() Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 11/32] tracing/filters: Fix false success return in process_system_preds() Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 12/32] tracing: Free tracer resources on instance creation failure Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 13/32] fgraph: Allocate shadow stacks inline with GFP_NOWAIT Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 14/32] fgraph: Use scoped_guard() for the task list walk Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 15/32] fgraph: Read the task->ret_stack with a smp_load_acquire() Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 16/32] tracing/osnoise: Dont start a kthread in timerlat user-space mode Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 17/32] tracing/user_events: Dont free an event that a dynamic event still references Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 18/32] tracing: Wait for marker writers when copy_trace_marker is cleared Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 19/32] tracing: Validate user addresses in faultable buffer copies Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 20/32] fgraph: Do not mark index 0 in every shadow stack frame Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 21/32] ring-buffer: Skip remote reader page swap when on tail Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 22/32] ring-buffer: Check remote reader page commit before meta entries Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 23/32] ring-buffer: Order remote page commit with data and timestamp Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 24/32] ring-buffer: Increment pages_read on remote ring buffer page swap Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 25/32] tracing/hwlat: Do the latency calculations in nanoseconds Steven Rostedt
2026-11-20 17:39 ` Steven Rostedt [this message]
2026-11-20 17:39 ` [for-linus][PATCH 27/32] tracing: Add tests for globbing number-based strings Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 28/32] tracing: Take trace_access_lock() in tracing_buffers_ioctl() Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 29/32] tracing: Do not allow user events to add a system name Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 30/32] ring-buffer: Do not check si_mem_available() before deferred init completes Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 31/32] tracing: Add notrace to event functions that hook to ftrace Steven Rostedt
2026-11-20 17:39 ` [for-linus][PATCH 32/32] tracing: Ignore .function on the function trace event Steven Rostedt

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=20261120174118.891370080@kernel.org \
    --to=rostedt@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=briannorris@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®