File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
tools/testing/selftests/bpf/progs Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,13 @@ struct {
50
50
__uint (map_flags , BPF_F_NO_PREALLOC );
51
51
} sk_storage_map SEC (".maps" );
52
52
53
+ struct {
54
+ __uint (type , BPF_MAP_TYPE_PROG_ARRAY );
55
+ __uint (max_entries , 1 );
56
+ __uint (key_size , sizeof (__u32 ));
57
+ __uint (value_size , sizeof (__u32 ));
58
+ } jmp_table SEC (".maps" );
59
+
53
60
SEC ("cgroup/skb" )
54
61
__description ("skb->sk: no NULL check" )
55
62
__failure __msg ("invalid mem access 'sock_common_or_null'" )
@@ -1065,4 +1072,25 @@ int invalidate_pkt_pointers_from_global_func(struct __sk_buff *sk)
1065
1072
return TCX_PASS ;
1066
1073
}
1067
1074
1075
+ __noinline
1076
+ int tail_call (struct __sk_buff * sk )
1077
+ {
1078
+ bpf_tail_call_static (sk , & jmp_table , 0 );
1079
+ return 0 ;
1080
+ }
1081
+
1082
+ /* Tail calls invalidate packet pointers. */
1083
+ SEC ("tc" )
1084
+ __failure __msg ("invalid mem access" )
1085
+ int invalidate_pkt_pointers_by_tail_call (struct __sk_buff * sk )
1086
+ {
1087
+ int * p = (void * )(long )sk -> data ;
1088
+
1089
+ if ((void * )(p + 1 ) > (void * )(long )sk -> data_end )
1090
+ return TCX_DROP ;
1091
+ tail_call (sk );
1092
+ * p = 42 ; /* this is unsafe */
1093
+ return TCX_PASS ;
1094
+ }
1095
+
1068
1096
char _license [] SEC ("license" ) = "GPL" ;
You can’t perform that action at this time.
0 commit comments