mirror of
https://github.com/torvalds/linux.git
synced 2026-11-26 16:33:17 +00:00
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: 35578d7984 ("bpf: Implement function bpf_perf_event_read() that get the selected hardware PMU conuter")
Signed-off-by: Alexei Starovoitov <[email protected]>
Tested-by: Wang Nan <[email protected]>
Signed-off-by: David S. Miller <[email protected]>