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 @@ -1037,4 +1037,32 @@ __naked void sock_create_read_src_port(void)
1037
1037
: __clobber_all );
1038
1038
}
1039
1039
1040
+ __noinline
1041
+ long skb_pull_data2 (struct __sk_buff * sk , __u32 len )
1042
+ {
1043
+ return bpf_skb_pull_data (sk , len );
1044
+ }
1045
+
1046
+ __noinline
1047
+ long skb_pull_data1 (struct __sk_buff * sk , __u32 len )
1048
+ {
1049
+ return skb_pull_data2 (sk , len );
1050
+ }
1051
+
1052
+ /* global function calls bpf_skb_pull_data(), which invalidates packet
1053
+ * pointers established before global function call.
1054
+ */
1055
+ SEC ("tc" )
1056
+ __failure __msg ("invalid mem access" )
1057
+ int invalidate_pkt_pointers_from_global_func (struct __sk_buff * sk )
1058
+ {
1059
+ int * p = (void * )(long )sk -> data ;
1060
+
1061
+ if ((void * )(p + 1 ) > (void * )(long )sk -> data_end )
1062
+ return TCX_DROP ;
1063
+ skb_pull_data1 (sk , 0 );
1064
+ * p = 42 ; /* this is unsafe */
1065
+ return TCX_PASS ;
1066
+ }
1067
+
1040
1068
char _license [] SEC ("license" ) = "GPL" ;
You can’t perform that action at this time.
0 commit comments