File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed
tools/testing/selftests/bpf Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 21
21
#include "verifier_cgroup_inv_retcode.skel.h"
22
22
#include "verifier_cgroup_skb.skel.h"
23
23
#include "verifier_cgroup_storage.skel.h"
24
+ #include "verifier_const.skel.h"
24
25
#include "verifier_const_or.skel.h"
25
26
#include "verifier_ctx.skel.h"
26
27
#include "verifier_ctx_sk_msg.skel.h"
@@ -146,6 +147,7 @@ void test_verifier_cfg(void) { RUN(verifier_cfg); }
146
147
void test_verifier_cgroup_inv_retcode (void ) { RUN (verifier_cgroup_inv_retcode ); }
147
148
void test_verifier_cgroup_skb (void ) { RUN (verifier_cgroup_skb ); }
148
149
void test_verifier_cgroup_storage (void ) { RUN (verifier_cgroup_storage ); }
150
+ void test_verifier_const (void ) { RUN (verifier_const ); }
149
151
void test_verifier_const_or (void ) { RUN (verifier_const_or ); }
150
152
void test_verifier_ctx (void ) { RUN (verifier_ctx ); }
151
153
void test_verifier_ctx_sk_msg (void ) { RUN (verifier_ctx_sk_msg ); }
Original file line number Diff line number Diff line change
1
+ // SPDX-License-Identifier: GPL-2.0
2
+ /* Copyright (c) 2024 Isovalent */
3
+
4
+ #include <linux/bpf.h>
5
+ #include <bpf/bpf_helpers.h>
6
+ #include "bpf_misc.h"
7
+
8
+ const volatile long foo = 42 ;
9
+ long bar ;
10
+ long bart = 96 ;
11
+
12
+ SEC ("tc/ingress" )
13
+ __description ("rodata: write rejected" )
14
+ __failure __msg ("write into map forbidden" )
15
+ int tcx1 (struct __sk_buff * skb )
16
+ {
17
+ char buff [] = { '8' , '4' , '\0' };
18
+ bpf_strtol (buff , sizeof (buff ), 0 , (long * )& foo );
19
+ return TCX_PASS ;
20
+ }
21
+
22
+ SEC ("tc/ingress" )
23
+ __description ("bss: write accepted" )
24
+ __success
25
+ int tcx2 (struct __sk_buff * skb )
26
+ {
27
+ char buff [] = { '8' , '4' , '\0' };
28
+ bpf_strtol (buff , sizeof (buff ), 0 , & bar );
29
+ return TCX_PASS ;
30
+ }
31
+
32
+ SEC ("tc/ingress" )
33
+ __description ("data: write accepted" )
34
+ __success
35
+ int tcx3 (struct __sk_buff * skb )
36
+ {
37
+ char buff [] = { '8' , '4' , '\0' };
38
+ bpf_strtol (buff , sizeof (buff ), 0 , & bart );
39
+ return TCX_PASS ;
40
+ }
41
+
42
+ char LICENSE [] SEC ("license" ) = "GPL" ;
You can’t perform that action at this time.
0 commit comments