All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tracing/filters: Fix MATCH_END_ONLY on dynamic char arrays
@ 2026-11-26 21:52 David Carlier
  0 siblings, 0 replies; only message in thread
From: David Carlier @ 2026-11-26 21:52 UTC (permalink / raw)
  To: Steven Rostedt, Masami Hiramatsu
  Cc: Mathieu Desnoyers, linux-trace-kernel, linux-kernel,
	David Carlier

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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-26 21:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 21:52 [PATCH] tracing/filters: Fix MATCH_END_ONLY on dynamic char arrays David Carlier

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.