1// SPDX-License-Identifier: GPL-2.0
2/* Copyright (C) 2023 Yafang Shao <laoar.shao@gmail.com> */
3
4#include "vmlinux.h"
5#include <bpf/bpf_tracing.h>
6
7char tp_name[128];
8
9SEC("lsm.s/bpf")
10int BPF_PROG(lsm_run, int cmd, union bpf_attr *attr, unsigned int size)
11{
12 switch (cmd) {
13 case BPF_RAW_TRACEPOINT_OPEN:
14 bpf_copy_from_user(tp_name, sizeof(tp_name) - 1,
15 (void *)attr->raw_tracepoint.name);
16 break;
17 default:
18 break;
19 }
20 return 0;
21}
22
23SEC("raw_tracepoint")
24int BPF_PROG(raw_tp_run)
25{
26 return 0;
27}
28
29char _license[] SEC("license") = "GPL";
30

source code of linux/tools/testing/selftests/bpf/progs/test_ptr_untrusted.c