Skip to content

Commit 7d65df7

Browse files
mannkafaiKernel Patches Daemon
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]>
1 parent 6978e3e commit 7d65df7

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
@@ -23932,7 +23932,8 @@ static int check_attach_btf_id(struct bpf_verifier_env *env)
2393223932
} else if ((prog->expected_attach_type == BPF_TRACE_FEXIT ||
2393323933
prog->expected_attach_type == BPF_MODIFY_RETURN) &&
2393423934
btf_id_set_contains(&noreturn_deny, btf_id)) {
23935-
verbose(env, "Attaching fexit/fmod_ret to __noreturn functions is rejected.\n");
23935+
verbose(env, "Attaching fexit/fmod_ret to __noreturn function '%s' is rejected.\n",
23936+
tgt_info.tgt_name);
2393623937
return -EINVAL;
2393723938
}
2393823939

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)