Skip to content

Commit 6080280

Browse files
eddyz87Alexei Starovoitov
authored andcommitted
selftests/bpf: verifier/d_path converted to inline assembly
Test verifier/d_path automatically converted to use inline assembly. Signed-off-by: Eduard Zingerman <eddyz87@gmail.com> Link: https://lore.kernel.org/r/20230421174234.2391278-7-eddyz87@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent fcd3696 commit 6080280

3 files changed

Lines changed: 50 additions & 37 deletions

File tree

tools/testing/selftests/bpf/prog_tests/verifier.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "verifier_const_or.skel.h"
2020
#include "verifier_ctx.skel.h"
2121
#include "verifier_ctx_sk_msg.skel.h"
22+
#include "verifier_d_path.skel.h"
2223
#include "verifier_direct_stack_access_wraparound.skel.h"
2324
#include "verifier_div0.skel.h"
2425
#include "verifier_div_overflow.skel.h"
@@ -99,6 +100,7 @@ void test_verifier_cgroup_storage(void) { RUN(verifier_cgroup_storage); }
99100
void test_verifier_const_or(void) { RUN(verifier_const_or); }
100101
void test_verifier_ctx(void) { RUN(verifier_ctx); }
101102
void test_verifier_ctx_sk_msg(void) { RUN(verifier_ctx_sk_msg); }
103+
void test_verifier_d_path(void) { RUN(verifier_d_path); }
102104
void test_verifier_direct_stack_access_wraparound(void) { RUN(verifier_direct_stack_access_wraparound); }
103105
void test_verifier_div0(void) { RUN(verifier_div0); }
104106
void test_verifier_div_overflow(void) { RUN(verifier_div_overflow); }
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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";

tools/testing/selftests/bpf/verifier/d_path.c

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)