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'" )
@@ -1005,4 +1012,25 @@ int invalidate_pkt_pointers_from_global_func(struct __sk_buff *sk)
1005
1012
return TCX_PASS ;
1006
1013
}
1007
1014
1015
+ __noinline
1016
+ int tail_call (struct __sk_buff * sk )
1017
+ {
1018
+ bpf_tail_call_static (sk , & jmp_table , 0 );
1019
+ return 0 ;
1020
+ }
1021
+
1022
+ /* Tail calls invalidate packet pointers. */
1023
+ SEC ("tc" )
1024
+ __failure __msg ("invalid mem access" )
1025
+ int invalidate_pkt_pointers_by_tail_call (struct __sk_buff * sk )
1026
+ {
1027
+ int * p = (void * )(long )sk -> data ;
1028
+
1029
+ if ((void * )(p + 1 ) > (void * )(long )sk -> data_end )
1030
+ return TCX_DROP ;
1031
+ tail_call (sk );
1032
+ * p = 42 ; /* this is unsafe */
1033
+ return TCX_PASS ;
1034
+ }
1035
+
1008
1036
char _license [] SEC ("license" ) = "GPL" ;
You can’t perform that action at this time.
0 commit comments