File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
tools/testing/selftests/bpf/progs Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -1117,10 +1117,17 @@ int tail_call(struct __sk_buff *sk)
11171117 return 0 ;
11181118}
11191119
1120+ static __noinline
1121+ int static_tail_call (struct __sk_buff * sk )
1122+ {
1123+ bpf_tail_call_static (sk , & jmp_table , 0 );
1124+ return 0 ;
1125+ }
1126+
11201127/* Tail calls in sub-programs invalidate packet pointers. */
11211128SEC ("tc" )
11221129__failure __msg ("invalid mem access" )
1123- int invalidate_pkt_pointers_by_indirect_tail_call (struct __sk_buff * sk )
1130+ int invalidate_pkt_pointers_by_global_tail_call (struct __sk_buff * sk )
11241131{
11251132 int * p = (void * )(long )sk -> data ;
11261133
@@ -1131,6 +1138,20 @@ int invalidate_pkt_pointers_by_indirect_tail_call(struct __sk_buff *sk)
11311138 return TCX_PASS ;
11321139}
11331140
1141+ /* Tail calls in static sub-programs invalidate packet pointers. */
1142+ SEC ("tc" )
1143+ __failure __msg ("invalid mem access" )
1144+ int invalidate_pkt_pointers_by_static_tail_call (struct __sk_buff * sk )
1145+ {
1146+ int * p = (void * )(long )sk -> data ;
1147+
1148+ if ((void * )(p + 1 ) > (void * )(long )sk -> data_end )
1149+ return TCX_DROP ;
1150+ static_tail_call (sk );
1151+ * p = 42 ; /* this is unsafe */
1152+ return TCX_PASS ;
1153+ }
1154+
11341155/* Direct tail calls do not invalidate packet pointers. */
11351156SEC ("tc" )
11361157__success
You can’t perform that action at this time.
0 commit comments