1// SPDX-License-Identifier: GPL-2.0
2/* Converted from tools/testing/selftests/bpf/verifier/d_path.c */
3
4#include <linux/bpf.h>
5#include <bpf/bpf_helpers.h>
6#include "bpf_misc.h"
7
8SEC("fentry/dentry_open")
9__description("d_path accept")
10__success __retval(0)
11__naked void d_path_accept(void)
12{
13 asm volatile (" \
14 r1 = *(u32*)(r1 + 0); \
15 r2 = r10; \
16 r2 += -8; \
17 r6 = 0; \
18 *(u64*)(r2 + 0) = r6; \
19 r3 = 8 ll; \
20 call %[bpf_d_path]; \
21 r0 = 0; \
22 exit; \
23" :
24 : __imm(bpf_d_path)
25 : __clobber_all);
26}
27
28SEC("fentry/d_path")
29__description("d_path reject")
30__failure __msg("helper call is not allowed in probe")
31__naked void d_path_reject(void)
32{
33 asm volatile (" \
34 r1 = *(u32*)(r1 + 0); \
35 r2 = r10; \
36 r2 += -8; \
37 r6 = 0; \
38 *(u64*)(r2 + 0) = r6; \
39 r3 = 8 ll; \
40 call %[bpf_d_path]; \
41 r0 = 0; \
42 exit; \
43" :
44 : __imm(bpf_d_path)
45 : __clobber_all);
46}
47
48char _license[] SEC("license") = "GPL";
49

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