From: David Carlier <devnexen@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org,
David Carlier <devnexen@gmail.com>
Subject: [PATCH] tracing/filters: Fix MATCH_END_ONLY on dynamic char arrays
Date: Thu, 26 Nov 2026 21:52:28 +0000 [thread overview]
Message-ID: <20261126215228.1205862-1-devnexen@gmail.com> (raw)
regex_match_end() takes the string length as "len - 1", which holds
for __string() fields where the length counts the trailing NUL. A
__dynamic_array() of char does not have to be NUL-terminated or
filled to its length. The xfs namespace events copy name->len bytes
with no NUL, so the compare is off by one:
# echo 'name ~ "*.txt"' > events/xfs/xfs_lookup/filter
misses "foo.txt" and matches "a.txtz".
Use regex_match_end_str() for dynamic strings as well, which finds
the end with strnlen().
Fixes: a3291c14ecf0 ("tracing/filters: Fix MATCH_END_ONLY filter matching")
Signed-off-by: David Carlier <devnexen@gmail.com>
---
kernel/trace/trace_events_filter.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index 42a57cb57ff9..68a20f5d68fa 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -2076,8 +2076,12 @@ static int parse_pred(const char *str, void *data,
} else if (field->filter_type == FILTER_DYN_STRING) {
pred->fn_num = FILTER_PRED_FN_STRLOC;
+ if (pred->regex->match == regex_match_end)
+ pred->regex->match = regex_match_end_str;
} else if (field->filter_type == FILTER_RDYN_STRING) {
pred->fn_num = FILTER_PRED_FN_STRRELLOC;
+ if (pred->regex->match == regex_match_end)
+ pred->regex->match = regex_match_end_str;
} else if (field->filter_type == FILTER_WITHIN) {
unsigned long func;
--
2.55.0
reply other threads:[~2026-11-26 21:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261126215228.1205862-1-devnexen@gmail.com \
--to=devnexen@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.