summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Rostedt (VMware) <rostedt@goodmis.org>2018-05-09 11:59:32 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-05-16 10:10:27 +0200
commit8999971292769c4f39cd6b0aa46df6973b588c3b (patch)
treebb1af607cb8fc84757056d5b1c0e34c1d8490704
parent586d02c1479f47483ca40dba463e4e5cbcd21241 (diff)
downloadlinux-8999971292769c4f39cd6b0aa46df6973b588c3b.tar.gz
linux-8999971292769c4f39cd6b0aa46df6973b588c3b.tar.bz2
linux-8999971292769c4f39cd6b0aa46df6973b588c3b.zip
tracing: Fix regex_match_front() to not over compare the test string
commit dc432c3d7f9bceb3de6f5b44fb9c657c9810ed6d 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: 285caad415f45 ("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>
-rw-r--r--kernel/trace/trace_events_filter.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index a764aec3c9a1..55008fa93097 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -338,6 +338,9 @@ static int regex_match_full(char *str, struct regex *r, int len)
static int regex_match_front(char *str, struct regex *r, int len)
{
+ if (len < r->len)
+ return 0;
+
if (strncmp(str, r->pattern, r->len) == 0)
return 1;
return 0;