mirror of
https://github.com/torvalds/linux.git
synced 2026-05-26 08:02:27 +02:00
selftests/bpf: Cover global subprog exception leaks
Add a verifier failure case where the caller holds a reference across a global subprog call that may throw. The program must be rejected because the exceptional path would skip the caller's reference release. Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Link: https://lore.kernel.org/r/20260517075530.3461166-3-memxor@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
parent
3d562d35a0
commit
511a5db3c9
|
|
@ -208,6 +208,28 @@ int reject_with_reference(void *ctx)
|
|||
return 0;
|
||||
}
|
||||
|
||||
__noinline int global_subprog_may_throw(struct __sk_buff *ctx)
|
||||
{
|
||||
if (ctx->len)
|
||||
bpf_throw(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
SEC("?tc")
|
||||
__failure __msg("Unreleased reference")
|
||||
int reject_global_subprog_throw_with_reference(struct __sk_buff *ctx)
|
||||
{
|
||||
struct foo *f;
|
||||
|
||||
f = bpf_obj_new(typeof(*f));
|
||||
if (!f)
|
||||
return 0;
|
||||
if (ctx->protocol)
|
||||
global_subprog_may_throw(ctx);
|
||||
bpf_obj_drop(f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
__noinline static int subprog_ref(struct __sk_buff *ctx)
|
||||
{
|
||||
struct foo *f;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user