From: Steven Rostedt <rostedt@goodmis.org>
To: David Carlier <devnexen@gmail.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] tracing/filters: Fix MATCH_END_ONLY on dynamic char arrays
Date: Thu, 3 Dec 2026 14:39:22 -0500 [thread overview]
Message-ID: <20261203143922.416a7fa5@gandalf.local.home> (raw)
In-Reply-To: <20261203145822.591395-1-devnexen@gmail.com>
On Thu, 3 Dec 2026 14:58:22 +0000
David Carlier <devnexen@gmail.com> wrote:
> regex_match_end() assumes the length counts a trailing NUL, which is
> wrong for a __dynamic_array() of char. On xfs_lookup,
> 'name ~ "*.txt"' misses "foo.txt" and matches "a.txtz".
>
> Remove it and use regex_match_end_str() for all MATCH_END_ONLY
> filters. The char pointer path passes strlen() + 1, so it behaves the
> same as before.
>
> Fixes: a3291c14ecf0 ("tracing/filters: Fix MATCH_END_ONLY filter matching")
> Suggested-by: Steven Rostedt <rostedt@goodmis.org>
> Signed-off-by: David Carlier <devnexen@gmail.com>
> ---
> Changes in v2:
> - Remove regex_match_end() and use regex_match_end_str() for all
> MATCH_END_ONLY filters (Steven)
> - v1: https://lore.kernel.org/linux-trace-kernel/20261126215228.1205862-1-devnexen@gmail.com/
>
> kernel/trace/trace_events_filter.c | 24 ++++--------------------
> 1 file changed, 4 insertions(+), 20 deletions(-)
>
> diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
> index 42a57cb57ff9..93fa6f6e3124 100644
> --- a/kernel/trace/trace_events_filter.c
> +++ b/kernel/trace/trace_events_filter.c
> @@ -1082,16 +1082,6 @@ static int regex_match_middle(char *str, struct regex *r, int len)
> return strnstr(str, r->pattern, len) != NULL;
> }
>
> -static int regex_match_end(char *str, struct regex *r, int len)
> -{
> - int strlen = len - 1;
> -
> - if (strlen >= r->len &&
> - memcmp(str + strlen - r->len, r->pattern, r->len) == 0)
> - return 1;
> - return 0;
> -}
> -
> static int regex_match_end_str(char *str, struct regex *r, int len)
Actually I was also thinking this should rename regex_match_end_str to
regex_match_end() and the dynamic one to regex_match_end_dyn()
-- Steve
> {
> int slen;
> @@ -1203,7 +1193,7 @@ static void filter_build_regex(struct filter_pred *pred)
> r->match = regex_match_middle;
> break;
> case MATCH_END_ONLY:
> - r->match = regex_match_end;
> + r->match = regex_match_end_str;
> break;
> case MATCH_GLOB:
> r->match = regex_match_glob;
> @@ -2061,18 +2051,12 @@ static int parse_pred(const char *str, void *data,
>
> if (field->filter_type == FILTER_COMM) {
> pred->fn_num = FILTER_PRED_FN_COMM;
> - if (pred->regex->match == regex_match_end)
> - pred->regex->match = regex_match_end_str;
> -
> } else if (field->filter_type == FILTER_STATIC_STRING) {
> pred->fn_num = FILTER_PRED_FN_STRING;
> pred->regex->field_len = field->size;
> - if (pred->regex->match == regex_match_end) {
> - if (!field->size)
> - pred->regex->match = regex_match_end_dynstr;
> - else
> - pred->regex->match = regex_match_end_str;
> - }
> + if (pred->regex->match == regex_match_end_str &&
> + !field->size)
> + pred->regex->match = regex_match_end_dynstr;
>
> } else if (field->filter_type == FILTER_DYN_STRING) {
> pred->fn_num = FILTER_PRED_FN_STRLOC;
prev parent reply other threads:[~2026-12-03 19:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 14:58 [PATCH v2] tracing/filters: Fix MATCH_END_ONLY on dynamic char arrays David Carlier
2026-12-03 19:28 ` kernel test robot
2026-12-03 19:39 ` Steven Rostedt [this message]
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=20261203143922.416a7fa5@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=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 \
/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