]> git.karo-electronics.de Git - karo-tx-linux.git/commit
bpf: fix bpf_perf_event_read() helper
authorAlexei Starovoitov <ast@plumgrid.com>
Fri, 23 Oct 2015 00:10:14 +0000 (17:10 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 27 Oct 2015 04:49:26 +0000 (21:49 -0700)
commit62544ce8e01c1879d420ba309f7f319d24c0f4e6
tree394d2f12e6a065b53b3d71bd89ea4b931ce3ec71
parent8b7c94e3478dbb0296293b43a974c3561d01e9fb
bpf: fix bpf_perf_event_read() helper

Fix safety checks for bpf_perf_event_read():
- only non-inherited events can be added to perf_event_array map
  (do this check statically at map insertion time)
- dynamically check that event is local and !pmu->count
Otherwise buggy bpf program can cause kernel splat.

Also fix error path after perf_event_attrs()
and remove redundant 'extern'.

Fixes: 35578d798400 ("bpf: Implement function bpf_perf_event_read() that get the selected hardware PMU conuter")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Tested-by: Wang Nan <wangnan0@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/bpf.h
kernel/bpf/arraymap.c
kernel/trace/bpf_trace.c