Loading...
1// SPDX-License-Identifier: GPL-2.0
2/* Converted from tools/testing/selftests/bpf/verifier/btf_ctx_access.c */
3
4#include <linux/bpf.h>
5#include <bpf/bpf_helpers.h>
6#include "bpf_misc.h"
7
8SEC("fentry/bpf_modify_return_test")
9__description("btf_ctx_access accept")
10__success __retval(0)
11__naked void btf_ctx_access_accept(void)
12{
13 asm volatile (" \
14 r2 = *(u64 *)(r1 + 8); /* load 2nd argument value (int pointer) */\
15 r0 = 0; \
16 exit; \
17" ::: __clobber_all);
18}
19
20SEC("fentry/bpf_fentry_test9")
21__description("btf_ctx_access u32 pointer accept")
22__success __retval(0)
23__naked void ctx_access_u32_pointer_accept(void)
24{
25 asm volatile (" \
26 r2 = *(u64 *)(r1 + 0); /* load 1nd argument value (u32 pointer) */\
27 r0 = 0; \
28 exit; \
29" ::: __clobber_all);
30}
31
32SEC("fentry/bpf_fentry_test9")
33__description("btf_ctx_access u32 pointer reject u32")
34__failure __msg("size 4 must be 8")
35__naked void ctx_access_u32_pointer_reject_32(void)
36{
37 asm volatile (" \
38 r2 = *(u32 *)(r1 + 0); /* load 1st argument with narrow load */\
39 r0 = 0; \
40 exit; \
41" ::: __clobber_all);
42}
43
44SEC("fentry/bpf_fentry_test9")
45__description("btf_ctx_access u32 pointer reject u16")
46__failure __msg("size 2 must be 8")
47__naked void ctx_access_u32_pointer_reject_16(void)
48{
49 asm volatile (" \
50 r2 = *(u16 *)(r1 + 0); /* load 1st argument with narrow load */\
51 r0 = 0; \
52 exit; \
53" ::: __clobber_all);
54}
55
56SEC("fentry/bpf_fentry_test9")
57__description("btf_ctx_access u32 pointer reject u8")
58__failure __msg("size 1 must be 8")
59__naked void ctx_access_u32_pointer_reject_8(void)
60{
61 asm volatile (" \
62 r2 = *(u8 *)(r1 + 0); /* load 1st argument with narrow load */\
63 r0 = 0; \
64 exit; \
65" ::: __clobber_all);
66}
67
68char _license[] SEC("license") = "GPL";
1// SPDX-License-Identifier: GPL-2.0
2/* Converted from tools/testing/selftests/bpf/verifier/btf_ctx_access.c */
3
4#include <linux/bpf.h>
5#include <bpf/bpf_helpers.h>
6#include "bpf_misc.h"
7
8SEC("fentry/bpf_modify_return_test")
9__description("btf_ctx_access accept")
10__success __retval(0)
11__naked void btf_ctx_access_accept(void)
12{
13 asm volatile (" \
14 r2 = *(u32*)(r1 + 8); /* load 2nd argument value (int pointer) */\
15 r0 = 0; \
16 exit; \
17" ::: __clobber_all);
18}
19
20SEC("fentry/bpf_fentry_test9")
21__description("btf_ctx_access u32 pointer accept")
22__success __retval(0)
23__naked void ctx_access_u32_pointer_accept(void)
24{
25 asm volatile (" \
26 r2 = *(u32*)(r1 + 0); /* load 1nd argument value (u32 pointer) */\
27 r0 = 0; \
28 exit; \
29" ::: __clobber_all);
30}
31
32char _license[] SEC("license") = "GPL";