Skip to content

Commit f94eef3

Browse files
rostedtgregkh
authored andcommitted
tracing: Fix regex_match_front() to not over compare the test string
commit dc432c3 upstream. 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: stable@vger.kernel.org Fixes: 285caad ("tracing/filters: Fix MATCH_FRONT_ONLY filter matching") Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b269209 commit f94eef3

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

kernel/trace/trace_events_filter.c

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

323323
static int regex_match_front(char *str, struct regex *r, int len)
324324
{
325+
if (len < r->len)
326+
return 0;
327+
325328
if (strncmp(str, r->pattern, r->len) == 0)
326329
return 1;
327330
return 0;

0 commit comments

Comments
 (0)