File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
tools/testing/selftests/bpf/progs Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -1124,6 +1124,13 @@ int static_tail_call(struct __sk_buff *sk)
11241124 return 0 ;
11251125}
11261126
1127+ static __noinline
1128+ int * static_tail_call_return (struct __sk_buff * sk )
1129+ {
1130+ bpf_tail_call_static (sk , & jmp_table , 0 );
1131+ return (void * )(long )sk -> data ;
1132+ }
1133+
11271134/* Tail calls in sub-programs invalidate packet pointers. */
11281135SEC ("tc" )
11291136__failure __msg ("invalid mem access" )
@@ -1166,4 +1173,18 @@ int invalidate_pkt_pointers_by_tail_call(struct __sk_buff *sk)
11661173 return TCX_PASS ;
11671174}
11681175
1176+ /* Direct tail calls do not invalidate packet pointers. */
1177+ SEC ("tc" )
1178+ __success
1179+ int invalidate_pkt_pointers_by_tail_call_return (struct __sk_buff * sk )
1180+ {
1181+ int * p = (void * )(long )sk -> data ;
1182+
1183+ if ((void * )(p + 1 ) > (void * )(long )sk -> data_end )
1184+ return TCX_DROP ;
1185+ p = bpf_tail_call_return (sk , & jmp_table , 0 );
1186+ * p = 42 ; /* this is NOT unsafe: tail calls don't return */
1187+ return TCX_PASS ;
1188+ }
1189+
11691190char _license [] SEC ("license" ) = "GPL" ;
You can’t perform that action at this time.
0 commit comments