Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bpf: Handle return value of ftrace_set_filter_ip in register_fentry

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>

authored by

Menglong Dong and committed by
Alexei Starovoitov
fea3f5e8 e5d2e34e

+3 -1
+3 -1
kernel/bpf/trampoline.c
··· 220 220 } 221 221 222 222 if (tr->func.ftrace_managed) { 223 - ftrace_set_filter_ip(tr->fops, (unsigned long)ip, 0, 1); 223 + ret = ftrace_set_filter_ip(tr->fops, (unsigned long)ip, 0, 1); 224 + if (ret) 225 + return ret; 224 226 ret = register_ftrace_direct(tr->fops, (long)new_addr); 225 227 } else { 226 228 ret = bpf_arch_text_poke(ip, BPF_MOD_CALL, NULL, new_addr);