Skip to content

Commit 7030342

Browse files
committed
tracing: Check for no filter when processing event filters
The syzkaller detected a out-of-bounds issue with the events filter code, specifically here: prog[N].pred = NULL; /* #13 */ prog[N].target = 1; /* TRUE */ prog[N+1].pred = NULL; prog[N+1].target = 0; /* FALSE */ -> prog[N-1].target = N; prog[N-1].when_to_branch = false; As that's the first reference to a "N-1" index, it appears that the code got here with N = 0, which means the filter parser found no filter to parse (which shouldn't ever happen, but apparently it did). Add a new error to the parsing code that will check to make sure that N is not zero before going into this part of the code. If N = 0, then -EINVAL is returned, and a error message is added to the filter. Cc: [email protected] Fixes: 8076559 ("tracing: Rewrite filter logic to be simpler and faster") Reported-by: air icy <[email protected]> bugzilla url: https://bugzilla.kernel.org/show_bug.cgi?id=200019 Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent ce397d2 commit 7030342

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

kernel/trace/trace_events_filter.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ static const char * ops[] = { OPS };
7878
C(TOO_MANY_PREDS, "Too many terms in predicate expression"), \
7979
C(INVALID_FILTER, "Meaningless filter expression"), \
8080
C(IP_FIELD_ONLY, "Only 'ip' field is supported for function trace"), \
81-
C(INVALID_VALUE, "Invalid value (did you forget quotes)?"),
81+
C(INVALID_VALUE, "Invalid value (did you forget quotes)?"), \
82+
C(NO_FILTER, "No filter found"),
8283

8384
#undef C
8485
#define C(a, b) FILT_ERR_##a
@@ -550,6 +551,13 @@ predicate_parse(const char *str, int nr_parens, int nr_preds,
550551
goto out_free;
551552
}
552553

554+
if (!N) {
555+
/* No program? */
556+
ret = -EINVAL;
557+
parse_error(pe, FILT_ERR_NO_FILTER, ptr - str);
558+
goto out_free;
559+
}
560+
553561
prog[N].pred = NULL; /* #13 */
554562
prog[N].target = 1; /* TRUE */
555563
prog[N+1].pred = NULL;

0 commit comments

Comments
 (0)