]> git.baikalelectronics.ru Git - kernel.git/commit
tracing: Fix regex_match_front() to not over compare the test string
authorSteven Rostedt (VMware) <rostedt@goodmis.org>
Wed, 9 May 2018 15:59:32 +0000 (11:59 -0400)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Fri, 11 May 2018 14:56:42 +0000 (10:56 -0400)
commit615c104f45639f1e339dd4274ad98a44ca85e158
tree3d482664e656bb402a4b16c5d4e88ec1f57cb8df
parentafa228a6773efce28def42a14cc737f0fbf48cd7
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: stable@vger.kernel.org
Fixes: b779d9ff74255 ("tracing/filters: Fix MATCH_FRONT_ONLY filter matching")
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
kernel/trace/trace_events_filter.c