mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-23 05:56:14 -04:00
selftests/bpf: Test returning referenced kptr from struct_ops programs
Test struct_ops programs returning referenced kptr. When the return type of a struct_ops operator is pointer to struct, the verifier should only allow programs that return a scalar NULL or a non-local kptr with the correct type in its unmodified form. Signed-off-by: Amery Hung <amery.hung@bytedance.com> Acked-by: Eduard Zingerman <eddyz87@gmail.com> Acked-by: Martin KaFai Lau <martin.lau@kernel.org> Link: https://lore.kernel.org/r/20250217190640.1748177-6-ameryhung@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
committed by
Alexei Starovoitov
parent
8d9f547f74
commit
af17bad9fb
@@ -1182,11 +1182,19 @@ static int bpf_testmod_ops__test_refcounted(int dummy,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct task_struct *
|
||||
bpf_testmod_ops__test_return_ref_kptr(int dummy, struct task_struct *task__ref,
|
||||
struct cgroup *cgrp)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct bpf_testmod_ops __bpf_testmod_ops = {
|
||||
.test_1 = bpf_testmod_test_1,
|
||||
.test_2 = bpf_testmod_test_2,
|
||||
.test_maybe_null = bpf_testmod_ops__test_maybe_null,
|
||||
.test_refcounted = bpf_testmod_ops__test_refcounted,
|
||||
.test_return_ref_kptr = bpf_testmod_ops__test_return_ref_kptr,
|
||||
};
|
||||
|
||||
struct bpf_struct_ops bpf_bpf_testmod_ops = {
|
||||
|
||||
Reference in New Issue
Block a user