Commit a5a6b29a authored by KaFai Wan's avatar KaFai Wan Committed by Alexei Starovoitov
Browse files

bpf: Show precise rejected function when attaching fexit/fmod_ret to __noreturn functions



With this change, we know the precise rejected function name when
attaching fexit/fmod_ret to __noreturn functions from log.

$ ./fexit
libbpf: prog 'fexit': BPF program load failed: -EINVAL
libbpf: prog 'fexit': -- BEGIN PROG LOAD LOG --
Attaching fexit/fmod_ret to __noreturn function 'do_exit' is rejected.

Suggested-by: default avatarLeon Hwang <leon.hwang@linux.dev>
Signed-off-by: default avatarKaFai Wan <kafai.wan@linux.dev>
Acked-by: default avatarYafang Shao <laoar.shao@gmail.com>
Acked-by: default avatarYonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20250724151454.499040-2-kafai.wan@linux.dev


Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 5b4c54ac
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -23985,7 +23985,8 @@ static int check_attach_btf_id(struct bpf_verifier_env *env)
	} else if ((prog->expected_attach_type == BPF_TRACE_FEXIT ||
		   prog->expected_attach_type == BPF_MODIFY_RETURN) &&
		   btf_id_set_contains(&noreturn_deny, btf_id)) {
		verbose(env, "Attaching fexit/fmod_ret to __noreturn functions is rejected.\n");
		verbose(env, "Attaching fexit/fmod_ret to __noreturn function '%s' is rejected.\n",
			tgt_info.tgt_name);
		return -EINVAL;
	}
+1 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@
char _license[] SEC("license") = "GPL";

SEC("fexit/do_exit")
__failure __msg("Attaching fexit/fmod_ret to __noreturn functions is rejected.")
__failure __msg("Attaching fexit/fmod_ret to __noreturn function 'do_exit' is rejected.")
int BPF_PROG(noreturns)
{
	return 0;