diff options
author | Alexei Starovoitov <ast@fb.com> | 2016-06-16 03:25:39 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-06-16 08:37:54 +0200 |
commit | ad572d174787daa59e24b8b5c83028c09cdb5ddb (patch) | |
tree | 742f85968aea27bc975164e839dbc00312d3184a /kernel/trace | |
parent | bpf: fix matching of data/data_end in verifier (diff) | |
download | linux-ad572d174787daa59e24b8b5c83028c09cdb5ddb.tar.xz linux-ad572d174787daa59e24b8b5c83028c09cdb5ddb.zip |
bpf, trace: check event type in bpf_perf_event_read
similar to bpf_perf_event_output() the bpf_perf_event_read() helper
needs to check the type of the perf_event before reading the counter.
Fixes: a43eec304259 ("bpf: introduce bpf_perf_event_output() helper")
Reported-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'kernel/trace')
-rw-r--r-- | kernel/trace/bpf_trace.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index e7af6cb9d5cf..26f603da7e26 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c @@ -209,6 +209,10 @@ static u64 bpf_perf_event_read(u64 r1, u64 index, u64 r3, u64 r4, u64 r5) event->pmu->count) return -EINVAL; + if (unlikely(event->attr.type != PERF_TYPE_HARDWARE && + event->attr.type != PERF_TYPE_RAW)) + return -EINVAL; + /* * we don't know if the function is run successfully by the * return value. It can be judged in other places, such as |