]> git.hungrycats.org Git - linux/commit
bpf,perf: Fix perf_event_detach_bpf_prog error handling
authorJiri Olsa <jolsa@kernel.org>
Wed, 23 Oct 2024 20:03:52 +0000 (22:03 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 1 Nov 2024 00:56:05 +0000 (01:56 +0100)
commit7a5c653ede645693422e43cccaa3e8f905d21c74
tree1f0d826f77a18a6f40b82d1579ab1294a7a6f9ea
parent876ac72d535fa94f4ac57bba651987c6f990f646
bpf,perf: Fix perf_event_detach_bpf_prog error handling

[ Upstream commit 0ee288e69d033850bc87abe0f9cc3ada24763d7f ]

Peter reported that perf_event_detach_bpf_prog might skip to release
the bpf program for -ENOENT error from bpf_prog_array_copy.

This can't happen because bpf program is stored in perf event and is
detached and released only when perf event is freed.

Let's drop the -ENOENT check and make sure the bpf program is released
in any case.

Fixes: 170a7e3ea070 ("bpf: bpf_prog_array_copy() should return -ENOENT if exclude_prog not found")
Reported-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20241023200352.3488610-1-jolsa@kernel.org
Closes: https://lore.kernel.org/lkml/20241022111638.GC16066@noisy.programming.kicks-ass.net/
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/trace/bpf_trace.c