1 // SPDX-License-Identifier: GPL-2.0 2 /* Copyright (c) 2025 Meta Platforms, Inc. and affiliates. */ 3 #include <vmlinux.h> 4 #include <bpf/bpf_tracing.h> 5 #include "../test_kmods/bpf_testmod.h" 6 #include "bpf_misc.h" 7 8 char _license[] SEC("license") = "GPL"; 9 10 struct { 11 __uint(type, BPF_MAP_TYPE_PROG_ARRAY); 12 __uint(max_entries, 1); 13 __uint(key_size, sizeof(__u32)); 14 __uint(value_size, sizeof(__u32)); 15 } prog_array SEC(".maps"); 16 17 /* Test that the verifier rejects a program with referenced kptr arguments 18 * that tail call 19 */ 20 SEC("struct_ops/test_refcounted") 21 __failure __msg("program with __ref argument cannot tail call") refcounted_fail__tail_call(unsigned long long * ctx)22int refcounted_fail__tail_call(unsigned long long *ctx) 23 { 24 struct task_struct *task = (struct task_struct *)ctx[1]; 25 26 bpf_task_release(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 = (void *)refcounted_fail__tail_call, 35 }; 36 37