diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-06-18 02:56:57 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-06-18 02:56:57 -0400 |
commit | 17fda38f15953c398a2a0ae427928873c5c8c47c (patch) | |
tree | 9e414afe607930160f751d60a6255f67113ca980 /kernel | |
parent | 32e0e382ee51f34e9c42b3c69a1fd474bcfd449c (diff) | |
parent | 2cf30dc180cea808077f003c5116388183e54f9e (diff) |
Merge tag 'trace-fix-filter-4.1-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull tracing filter fix from Steven Rostedt:
"Vince Weaver reported a warning when he added perf event filters into
his fuzzer tests. There's a missing check of balanced operations when
parenthesis are used, and this triggers a WARN_ON() and when reading
the failure, the filter reports no failure occurred.
The operands were not being checked if they match, this adds that"
* tag 'trace-fix-filter-4.1-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
tracing: Have filter check for balanced ops
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/trace/trace_events_filter.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c index ced69da0ff55..7f2e97ce71a7 100644 --- a/kernel/trace/trace_events_filter.c +++ b/kernel/trace/trace_events_filter.c | |||
@@ -1369,19 +1369,26 @@ static int check_preds(struct filter_parse_state *ps) | |||
1369 | { | 1369 | { |
1370 | int n_normal_preds = 0, n_logical_preds = 0; | 1370 | int n_normal_preds = 0, n_logical_preds = 0; |
1371 | struct postfix_elt *elt; | 1371 | struct postfix_elt *elt; |
1372 | int cnt = 0; | ||
1372 | 1373 | ||
1373 | list_for_each_entry(elt, &ps->postfix, list) { | 1374 | list_for_each_entry(elt, &ps->postfix, list) { |
1374 | if (elt->op == OP_NONE) | 1375 | if (elt->op == OP_NONE) { |
1376 | cnt++; | ||
1375 | continue; | 1377 | continue; |
1378 | } | ||
1376 | 1379 | ||
1377 | if (elt->op == OP_AND || elt->op == OP_OR) { | 1380 | if (elt->op == OP_AND || elt->op == OP_OR) { |
1378 | n_logical_preds++; | 1381 | n_logical_preds++; |
1382 | cnt--; | ||
1379 | continue; | 1383 | continue; |
1380 | } | 1384 | } |
1385 | if (elt->op != OP_NOT) | ||
1386 | cnt--; | ||
1381 | n_normal_preds++; | 1387 | n_normal_preds++; |
1388 | WARN_ON_ONCE(cnt < 0); | ||
1382 | } | 1389 | } |
1383 | 1390 | ||
1384 | if (!n_normal_preds || n_logical_preds >= n_normal_preds) { | 1391 | if (cnt != 1 || !n_normal_preds || n_logical_preds >= n_normal_preds) { |
1385 | parse_error(ps, FILT_ERR_INVALID_FILTER, 0); | 1392 | parse_error(ps, FILT_ERR_INVALID_FILTER, 0); |
1386 | return -EINVAL; | 1393 | return -EINVAL; |
1387 | } | 1394 | } |