Skip to content

Commit a5a6b29

Browse files
mannkafaiAlexei Starovoitov
authored andcommitted
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: Leon Hwang <[email protected]> Signed-off-by: KaFai Wan <[email protected]> Acked-by: Yafang Shao <[email protected]> Acked-by: Yonghong Song <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 5b4c54a commit a5a6b29

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

kernel/bpf/verifier.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23985,7 +23985,8 @@ static int check_attach_btf_id(struct bpf_verifier_env *env)
2398523985
} else if ((prog->expected_attach_type == BPF_TRACE_FEXIT ||
2398623986
prog->expected_attach_type == BPF_MODIFY_RETURN) &&
2398723987
btf_id_set_contains(&noreturn_deny, btf_id)) {
23988-
verbose(env, "Attaching fexit/fmod_ret to __noreturn functions is rejected.\n");
23988+
verbose(env, "Attaching fexit/fmod_ret to __noreturn function '%s' is rejected.\n",
23989+
tgt_info.tgt_name);
2398923990
return -EINVAL;
2399023991
}
2399123992

tools/testing/selftests/bpf/progs/fexit_noreturns.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
char _license[] SEC("license") = "GPL";
99

1010
SEC("fexit/do_exit")
11-
__failure __msg("Attaching fexit/fmod_ret to __noreturn functions is rejected.")
11+
__failure __msg("Attaching fexit/fmod_ret to __noreturn function 'do_exit' is rejected.")
1212
int BPF_PROG(noreturns)
1313
{
1414
return 0;

0 commit comments

Comments
 (0)