1 // SPDX-License-Identifier: GPL-2.0 2 /* Copyright (c) 2026 Varun R Mallya */ 3 4 #include <vmlinux.h> 5 #include <bpf/bpf_helpers.h> 6 #include <bpf/bpf_tracing.h> 7 #include "../test_kmods/bpf_testmod.h" 8 #include "bpf_misc.h" 9 10 char _license[] SEC("license") = "GPL"; 11 12 struct { 13 __uint(type, BPF_MAP_TYPE_PROG_ARRAY); 14 __uint(max_entries, 1); 15 __uint(key_size, sizeof(__u32)); 16 __uint(value_size, sizeof(__u32)); 17 } prog_array SEC(".maps"); 18 19 SEC("struct_ops/test_refcounted_multi") 20 __failure __msg("program with __ref argument cannot tail call") 21 int test_refcounted_multi(unsigned long long *ctx) 22 { 23 /* ctx[2] is used because the refcounted variable is the third argument */ 24 struct task_struct *refcounted_task = (struct task_struct *)ctx[2]; 25 26 bpf_task_release(refcounted_task); 27 bpf_tail_call(ctx, &prog_array, 0); 28 29 return 0; 30 } 31 32 SEC(".struct_ops.link") 33 struct bpf_testmod_ops testmod_ref_acquire = { 34 .test_refcounted_multi = (void *)test_refcounted_multi, 35 }; 36