xref: /linux/tools/testing/selftests/bpf/progs/verifier_default_trusted_ptr.c (revision f17b474e36647c23801ef8fdaf2255ab66dd2973)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright 2026 Google LLC.
4  */
5 
6 #include <vmlinux.h>
7 #include <bpf/bpf_helpers.h>
8 #include <bpf/bpf_tracing.h>
9 
10 #include "bpf_misc.h"
11 #include "../test_kmods/bpf_testmod_kfunc.h"
12 
13 SEC("syscall")
14 __success __retval(0)
15 int test_default_trusted_ptr(void *ctx)
16 {
17 	struct prog_test_member *trusted_ptr;
18 
19 	trusted_ptr = bpf_kfunc_get_default_trusted_ptr_test();
20 	/*
21 	 * Test BPF kfunc bpf_get_default_trusted_ptr_test() returns a
22 	 * PTR_TO_BTF_ID | PTR_TRUSTED, therefore it should be accepted when
23 	 * passed to a BPF kfunc only accepting KF_TRUSTED_ARGS.
24 	 */
25 	bpf_kfunc_put_default_trusted_ptr_test(trusted_ptr);
26 	return 0;
27 }
28 
29 char _license[] SEC("license") = "GPL";
30