Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
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
10char _license[] SEC("license") = "GPL";
11
12struct {
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
19SEC("struct_ops/test_refcounted_multi")
20__failure __msg("program with __ref argument cannot tail call")
21int 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
32SEC(".struct_ops.link")
33struct bpf_testmod_ops testmod_ref_acquire = {
34 .test_refcounted_multi = (void *)test_refcounted_multi,
35};