]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bpf: Return error for missed kprobe multi bpf program execution
authorJiri Olsa <jolsa@kernel.org>
Mon, 6 Jan 2025 17:50:47 +0000 (18:50 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 8 Jan 2025 17:39:58 +0000 (09:39 -0800)
When kprobe multi bpf program can't be executed due to recursion check,
we currently return 0 (success) to fprobe layer where it's ignored for
standard kprobe multi probes.

For kprobe session the success return value will make fprobe layer to
install return probe and try to execute it as well.

But the return session probe should not get executed, because the entry
part did not run. FWIW the return probe bpf program most likely won't get
executed, because its recursion check will likely fail as well, but we
don't need to run it in the first place.. also we can make this clear
and obvious.

It also affects missed counts for kprobe session program execution, which
are now doubled (extra count for not executed return probe).

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Link: https://lore.kernel.org/r/20250106175048.1443905-1-jolsa@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/trace/bpf_trace.c

index a90880f475af8375af378b13decfdb8729b1c7d2..fc657c0eeb3e745fc39e7c35ec677213f0549e32 100644 (file)
@@ -2802,7 +2802,7 @@ kprobe_multi_link_prog_run(struct bpf_kprobe_multi_link *link,
 
        if (unlikely(__this_cpu_inc_return(bpf_prog_active) != 1)) {
                bpf_prog_inc_misses_counter(link->link.prog);
-               err = 0;
+               err = 1;
                goto out;
        }