* [PATCH v3] tracing/filters: Fix MATCH_END_ONLY on dynamic char arrays
@ 2026-12-04 4:02 David Carlier
0 siblings, 0 replies; only message in thread
From: David Carlier @ 2026-12-04 4:02 UTC (permalink / raw)
To: Steven Rostedt, Masami Hiramatsu
Cc: Mathieu Desnoyers, linux-trace-kernel, linux-kernel
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".
Replace it with regex_match_end_str(), which uses strnlen(), for all
MATCH_END_ONLY filters and give that the regex_match_end() name.
Rename regex_match_end_dynstr() to regex_match_end_dyn() to match.
The char pointer path passes strlen() + 1, so it is unaffected.
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 v3:
- Rename regex_match_end_str() to regex_match_end() and
regex_match_end_dynstr() to regex_match_end_dyn() (Steven)
- v2: https://lore.kernel.org/linux-trace-kernel/20261203145822.591395-1-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..c38477a4bc51 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -1083,16 +1083,6 @@ static int regex_match_middle(char *str, struct regex *r, int len)
}
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)
{
int slen;
@@ -1106,7 +1096,7 @@ static int regex_match_end_str(char *str, struct regex *r, int len)
return 0;
}
-static int regex_match_end_dynstr(char *str, struct regex *r, int len)
+static int regex_match_end_dyn(char *str, struct regex *r, int len)
{
int slen = strlen(str);
@@ -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 &&
+ !field->size)
+ pred->regex->match = regex_match_end_dyn;
} else if (field->filter_type == FILTER_DYN_STRING) {
pred->fn_num = FILTER_PRED_FN_STRLOC;
base-commit: 52cb4f95588e12edff0420886fe32d5e2f7f2649
--
2.55.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-12-04 4:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 4:02 [PATCH v3] tracing/filters: Fix MATCH_END_ONLY on dynamic char arrays David Carlier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox