Skip to content

Commit 3e287cb

Browse files
committed
selftests/bpf: pass a pointer as ARG_ANYTHING to global func
Signed-off-by: Eduard Zingerman <[email protected]>
1 parent 9095202 commit 3e287cb

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,20 @@ int BPF_PROG(trusted_acq_rel, struct task_struct *task, u64 clone_flags)
179179
return subprog_trusted_acq_rel(task);
180180
}
181181

182+
__noinline u64 ptr_as_scalar_fn(u64 addr)
183+
{
184+
return *(u64 *)bpf_rdonly_cast((void *)addr, 0);
185+
}
186+
187+
SEC("socket")
188+
__success
189+
__retval(42)
190+
int ptr_as_scalar_param(void *ctx)
191+
{
192+
u64 v;
193+
194+
v = 42;
195+
return ptr_as_scalar_fn((u64)&v);
196+
}
197+
182198
char _license[] SEC("license") = "GPL";

0 commit comments

Comments
 (0)