aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-06-26 16:56:55 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-06-26 16:56:55 -0400
commitfcbc1777ce8b5edf831c1eca16c1a63c1e4f39fb (patch)
tree0e7a44cc4a55d7120b15b48d977e4a48bcd83213
parent099bfbfc7fbbe22356c02f0caf709ac32e1126ea (diff)
parentcc9e4bde03f2b4cfba52406c021364cbd2a4a0f3 (diff)
Merge tag 'trace-fixes-4.1' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull tracing fixes from Steven Rostedt: "This isn't my 4.2 pull request (yet). I found a few more bugs that I would have sent to fix 4.1, but since 4.1 is already out, I'm sending this before sending my 4.2 request (which is ready to go). After fixing the previous filter issue reported by Vince Weaver, I could not come up with a situation where the operand counter (cnt) could go below zero, so I added a WARN_ON_ONCE(cnt < 0). Vince was able to trigger that warn on with his fuzzer test, but didn't have a filter input that caused it. Later, Sasha Levin was able to trigger that same warning, and was able to give me the filter string that triggered it. It was simply a single operation ">". I wrapped the filtering code in a userspace program such that I could single step through the logic. With a single operator the operand counter can legitimately go below zero, and should be reported to the user as an error, but should not produce a kernel warning. The WARN_ON_ONCE(cnt < 0) should be just a "if (cnt < 0) break;" and the code following it will produce the error message for the user. While debugging this, I found that there was another bug that let the pointer to the filter string go beyond the filter string. This too was fixed. Finally, there was a typo in a stub function that only gets compiled if trace events is disabled but tracing is enabled (I'm not even sure that's possible)" * tag 'trace-fixes-4.1' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: tracing: Fix typo from "static inlin" to "static inline" tracing/filter: Do not allow infix to exceed end of string tracing/filter: Do not WARN on operand count going below zero
-rw-r--r--kernel/trace/trace.h2
-rw-r--r--kernel/trace/trace_events_filter.c10
2 files changed, 10 insertions, 2 deletions
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index d2612016de94..3d2ad5f83e94 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -1312,7 +1312,7 @@ void trace_event_init(void);
1312void trace_event_enum_update(struct trace_enum_map **map, int len); 1312void trace_event_enum_update(struct trace_enum_map **map, int len);
1313#else 1313#else
1314static inline void __init trace_event_init(void) { } 1314static inline void __init trace_event_init(void) { }
1315static inlin void trace_event_enum_update(struct trace_enum_map **map, int len) { } 1315static inline void trace_event_enum_update(struct trace_enum_map **map, int len) { }
1316#endif 1316#endif
1317 1317
1318extern struct trace_iterator *tracepoint_print_iter; 1318extern struct trace_iterator *tracepoint_print_iter;
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index 9d4a78f45dc4..1c92dfa1dd17 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -1056,6 +1056,9 @@ static void parse_init(struct filter_parse_state *ps,
1056 1056
1057static char infix_next(struct filter_parse_state *ps) 1057static char infix_next(struct filter_parse_state *ps)
1058{ 1058{
1059 if (!ps->infix.cnt)
1060 return 0;
1061
1059 ps->infix.cnt--; 1062 ps->infix.cnt--;
1060 1063
1061 return ps->infix.string[ps->infix.tail++]; 1064 return ps->infix.string[ps->infix.tail++];
@@ -1071,6 +1074,9 @@ static char infix_peek(struct filter_parse_state *ps)
1071 1074
1072static void infix_advance(struct filter_parse_state *ps) 1075static void infix_advance(struct filter_parse_state *ps)
1073{ 1076{
1077 if (!ps->infix.cnt)
1078 return;
1079
1074 ps->infix.cnt--; 1080 ps->infix.cnt--;
1075 ps->infix.tail++; 1081 ps->infix.tail++;
1076} 1082}
@@ -1385,7 +1391,9 @@ static int check_preds(struct filter_parse_state *ps)
1385 if (elt->op != OP_NOT) 1391 if (elt->op != OP_NOT)
1386 cnt--; 1392 cnt--;
1387 n_normal_preds++; 1393 n_normal_preds++;
1388 WARN_ON_ONCE(cnt < 0); 1394 /* all ops should have operands */
1395 if (cnt < 0)
1396 break;
1389 } 1397 }
1390 1398
1391 if (cnt != 1 || !n_normal_preds || n_logical_preds >= n_normal_preds) { 1399 if (cnt != 1 || !n_normal_preds || n_logical_preds >= n_normal_preds) {