]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bpf: Handle return value of ftrace_set_filter_ip in register_fentry
authorMenglong Dong <menglong8.dong@gmail.com>
Mon, 10 Nov 2025 12:07:05 +0000 (20:07 +0800)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 14 Nov 2025 21:31:30 +0000 (13:31 -0800)
The error that returned by ftrace_set_filter_ip() in register_fentry() is
not handled properly. Just fix it.

Fixes: 00963a2e75a8 ("bpf: Support bpf_trampoline on functions with IPMODIFY (e.g. livepatch)")
Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
Acked-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20251110120705.1553694-1-dongml2@chinatelecom.cn
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/trampoline.c

index 5949095e51c3d072cb323bba464160c7012eb404..3610c6db15ee424a828d2cd07bf515f93b84abc1 100644 (file)
@@ -220,7 +220,9 @@ static int register_fentry(struct bpf_trampoline *tr, void *new_addr)
        }
 
        if (tr->func.ftrace_managed) {
-               ftrace_set_filter_ip(tr->fops, (unsigned long)ip, 0, 1);
+               ret = ftrace_set_filter_ip(tr->fops, (unsigned long)ip, 0, 1);
+               if (ret)
+                       return ret;
                ret = register_ftrace_direct(tr->fops, (long)new_addr);
        } else {
                ret = bpf_arch_text_poke(ip, BPF_MOD_CALL, NULL, new_addr);