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 /* Test that the verifier rejects a program that acquires a referenced 9 * kptr through context without releasing the reference 10 */ 11 SEC("struct_ops/test_refcounted") 12 __failure __msg("Unreleased reference id=1 alloc_insn=0") BPF_PROG(refcounted_fail__ref_leak,int dummy,struct task_struct * task)13int BPF_PROG(refcounted_fail__ref_leak, int dummy, 14 struct task_struct *task) 15 { 16 return 0; 17 } 18 19 SEC(".struct_ops.link") 20 struct bpf_testmod_ops testmod_ref_acquire = { 21 .test_refcounted = (void *)refcounted_fail__ref_leak, 22 }; 23