FILE
struct_ops_refcounted_fail__global_subprog.c
File preview with syntax highlighting.
linux-6.19.14/tools/testing/selftests/bpf/progs/struct_ops_refcounted_fail__global_subprog.c
1#include <vmlinux.h> 2#include <bpf/bpf_tracing.h> 3#include "../test_kmods/bpf_testmod.h" 4#include "bpf_misc.h" 5 6char _license[] SEC("license") = "GPL"; 7 8extern void bpf_task_release(struct task_struct *p) __ksym; 9 10__noinline int subprog_release(__u64 *ctx __arg_ctx) 11{ 12 struct task_struct *task = (struct task_struct *)ctx[1]; 13 int dummy = (int)ctx[0]; 14 15 bpf_task_release(task); 16 17 return dummy + 1; 18} 19 20/* Test that the verifier rejects a program that contains a global 21 * subprogram with referenced kptr arguments 22 */ 23SEC("struct_ops/test_refcounted") 24__failure __log_level(2) 25__msg("Validating subprog_release() func#1...") 26__msg("invalid bpf_context access off=8. Reference may already be released") 27int refcounted_fail__global_subprog(unsigned long long *ctx) 28{ 29 struct task_struct *task = (struct task_struct *)ctx[1]; 30 31 bpf_task_release(task); 32 33 return subprog_release(ctx); 34} 35 36SEC(".struct_ops.link") 37struct bpf_testmod_ops testmod_ref_acquire = { 38 .test_refcounted = (void *)refcounted_fail__global_subprog, 39};
~/
Read-only file preview.