1 #include <vmlinux.h> 2 #include <bpf/bpf_tracing.h> 3 #include "../test_kmods/bpf_testmod.h" 4 #include "bpf_misc.h" 5 6 char _license[] SEC("license") = "GPL"; 7 8 __attribute__((nomerge)) extern void bpf_task_release(struct task_struct *p) __ksym; 9 10 /* This is a test BPF program that uses struct_ops to access a referenced 11 * kptr argument. This is a test for the verifier to ensure that it 12 * 1) recongnizes the task as a referenced object (i.e., ref_obj_id > 0), and 13 * 2) the same reference can be acquired from multiple paths as long as it 14 * has not been released. 15 */ 16 SEC("struct_ops/test_refcounted") BPF_PROG(refcounted,int dummy,struct task_struct * task)17int BPF_PROG(refcounted, int dummy, struct task_struct *task) 18 { 19 if (dummy == 1) 20 bpf_task_release(task); 21 else 22 bpf_task_release(task); 23 return 0; 24 } 25 26 SEC(".struct_ops.link") 27 struct bpf_testmod_ops testmod_refcounted = { 28 .test_refcounted = (void *)refcounted, 29 }; 30 31 32