mirror of
https://github.com/torvalds/linux.git
synced 2026-06-02 11:33:28 +02:00
bpf: Improve verifier log for resource leak on exit
The verifier log when leaking resources on BPF_EXIT may be a bit confusing, as it's a problem only when finally existing from the main prog, not from any of the subprogs. Hence, update the verifier error string and the corresponding selftests matching on it. Acked-by: Eduard Zingerman <eddyz87@gmail.com> Suggested-by: Eduard Zingerman <eddyz87@gmail.com> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Link: https://lore.kernel.org/r/20241204030400.208005-6-memxor@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
parent
c8e2ee1f3d
commit
cbd8730aea
|
|
@ -19102,7 +19102,7 @@ static int do_check(struct bpf_verifier_env *env)
|
|||
* match caller reference state when it exits.
|
||||
*/
|
||||
err = check_resource_leak(env, exception_exit, !env->cur_state->curframe,
|
||||
"BPF_EXIT instruction");
|
||||
"BPF_EXIT instruction in main prog");
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ int reject_subprog_with_lock(void *ctx)
|
|||
}
|
||||
|
||||
SEC("?tc")
|
||||
__failure __msg("BPF_EXIT instruction cannot be used inside bpf_rcu_read_lock-ed region")
|
||||
__failure __msg("BPF_EXIT instruction in main prog cannot be used inside bpf_rcu_read_lock-ed region")
|
||||
int reject_with_rcu_read_lock(void *ctx)
|
||||
{
|
||||
bpf_rcu_read_lock();
|
||||
|
|
@ -147,7 +147,7 @@ __noinline static int throwing_subprog(struct __sk_buff *ctx)
|
|||
}
|
||||
|
||||
SEC("?tc")
|
||||
__failure __msg("BPF_EXIT instruction cannot be used inside bpf_rcu_read_lock-ed region")
|
||||
__failure __msg("BPF_EXIT instruction in main prog cannot be used inside bpf_rcu_read_lock-ed region")
|
||||
int reject_subprog_with_rcu_read_lock(void *ctx)
|
||||
{
|
||||
bpf_rcu_read_lock();
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
#include "bpf_experimental.h"
|
||||
|
||||
SEC("?tc")
|
||||
__failure __msg("BPF_EXIT instruction cannot be used inside bpf_preempt_disable-ed region")
|
||||
__failure __msg("BPF_EXIT instruction in main prog cannot be used inside bpf_preempt_disable-ed region")
|
||||
int preempt_lock_missing_1(struct __sk_buff *ctx)
|
||||
{
|
||||
bpf_preempt_disable();
|
||||
|
|
@ -14,7 +14,7 @@ int preempt_lock_missing_1(struct __sk_buff *ctx)
|
|||
}
|
||||
|
||||
SEC("?tc")
|
||||
__failure __msg("BPF_EXIT instruction cannot be used inside bpf_preempt_disable-ed region")
|
||||
__failure __msg("BPF_EXIT instruction in main prog cannot be used inside bpf_preempt_disable-ed region")
|
||||
int preempt_lock_missing_2(struct __sk_buff *ctx)
|
||||
{
|
||||
bpf_preempt_disable();
|
||||
|
|
@ -23,7 +23,7 @@ int preempt_lock_missing_2(struct __sk_buff *ctx)
|
|||
}
|
||||
|
||||
SEC("?tc")
|
||||
__failure __msg("BPF_EXIT instruction cannot be used inside bpf_preempt_disable-ed region")
|
||||
__failure __msg("BPF_EXIT instruction in main prog cannot be used inside bpf_preempt_disable-ed region")
|
||||
int preempt_lock_missing_3(struct __sk_buff *ctx)
|
||||
{
|
||||
bpf_preempt_disable();
|
||||
|
|
@ -33,7 +33,7 @@ int preempt_lock_missing_3(struct __sk_buff *ctx)
|
|||
}
|
||||
|
||||
SEC("?tc")
|
||||
__failure __msg("BPF_EXIT instruction cannot be used inside bpf_preempt_disable-ed region")
|
||||
__failure __msg("BPF_EXIT instruction in main prog cannot be used inside bpf_preempt_disable-ed region")
|
||||
int preempt_lock_missing_3_minus_2(struct __sk_buff *ctx)
|
||||
{
|
||||
bpf_preempt_disable();
|
||||
|
|
@ -55,7 +55,7 @@ static __noinline void preempt_enable(void)
|
|||
}
|
||||
|
||||
SEC("?tc")
|
||||
__failure __msg("BPF_EXIT instruction cannot be used inside bpf_preempt_disable-ed region")
|
||||
__failure __msg("BPF_EXIT instruction in main prog cannot be used inside bpf_preempt_disable-ed region")
|
||||
int preempt_lock_missing_1_subprog(struct __sk_buff *ctx)
|
||||
{
|
||||
preempt_disable();
|
||||
|
|
@ -63,7 +63,7 @@ int preempt_lock_missing_1_subprog(struct __sk_buff *ctx)
|
|||
}
|
||||
|
||||
SEC("?tc")
|
||||
__failure __msg("BPF_EXIT instruction cannot be used inside bpf_preempt_disable-ed region")
|
||||
__failure __msg("BPF_EXIT instruction in main prog cannot be used inside bpf_preempt_disable-ed region")
|
||||
int preempt_lock_missing_2_subprog(struct __sk_buff *ctx)
|
||||
{
|
||||
preempt_disable();
|
||||
|
|
@ -72,7 +72,7 @@ int preempt_lock_missing_2_subprog(struct __sk_buff *ctx)
|
|||
}
|
||||
|
||||
SEC("?tc")
|
||||
__failure __msg("BPF_EXIT instruction cannot be used inside bpf_preempt_disable-ed region")
|
||||
__failure __msg("BPF_EXIT instruction in main prog cannot be used inside bpf_preempt_disable-ed region")
|
||||
int preempt_lock_missing_2_minus_1_subprog(struct __sk_buff *ctx)
|
||||
{
|
||||
preempt_disable();
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ l0_%=: r6 = r0; \
|
|||
|
||||
SEC("cgroup/skb")
|
||||
__description("spin_lock: test6 missing unlock")
|
||||
__failure __msg("BPF_EXIT instruction cannot be used inside bpf_spin_lock-ed region")
|
||||
__failure __msg("BPF_EXIT instruction in main prog cannot be used inside bpf_spin_lock-ed region")
|
||||
__failure_unpriv __msg_unpriv("")
|
||||
__naked void spin_lock_test6_missing_unlock(void)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user