Skip to content

Commit dc432c3

Browse files
committed
tracing: Fix regex_match_front() to not over compare the test string
The regex match function regex_match_front() in the tracing filter logic, was fixed to test just the pattern length from testing the entire test string. That is, it went from strncmp(str, r->pattern, len) to strcmp(str, r->pattern, r->len). The issue is that str is not guaranteed to be nul terminated, and if r->len is greater than the length of str, it can access more memory than is allocated. The solution is to add a simple test if (len < r->len) return 0. Cc: [email protected] Fixes: 285caad ("tracing/filters: Fix MATCH_FRONT_ONLY filter matching") Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent 75bc37f commit dc432c3

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

kernel/trace/trace_events_filter.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,9 @@ static int regex_match_full(char *str, struct regex *r, int len)
762762

763763
static int regex_match_front(char *str, struct regex *r, int len)
764764
{
765+
if (len < r->len)
766+
return 0;
767+
765768
if (strncmp(str, r->pattern, r->len) == 0)
766769
return 1;
767770
return 0;

0 commit comments

Comments
 (0)