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 
8 SEC("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 
28 SEC("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 
48 char _license[] SEC("license") = "GPL";
49