@@ -260,4 +260,57 @@ int untrusted_to_trusted(void *ctx)
260
260
return subprog_untrusted2 (bpf_get_current_task_btf ());
261
261
}
262
262
263
+ __weak int subprog_void_untrusted (void * p __arg_untrusted )
264
+ {
265
+ return * (int * )p ;
266
+ }
267
+
268
+ __weak int subprog_char_untrusted (char * p __arg_untrusted )
269
+ {
270
+ return * (int * )p ;
271
+ }
272
+
273
+ __weak int subprog_enum_untrusted (enum bpf_attach_type * p __arg_untrusted )
274
+ {
275
+ return * (int * )p ;
276
+ }
277
+
278
+ __weak int subprog_enum64_untrusted (enum scx_public_consts * p __arg_untrusted )
279
+ {
280
+ return * (int * )p ;
281
+ }
282
+
283
+ SEC ("tp_btf/sys_enter" )
284
+ __success
285
+ __log_level (2 )
286
+ __msg ("r1 = {{.*}}; {{.*}}R1_w=trusted_ptr_task_struct()" )
287
+ __msg ("Func#1 ('subprog_void_untrusted') is global and assumed valid." )
288
+ __msg ("Validating subprog_void_untrusted() func#1..." )
289
+ __msg (": R1=rdonly_untrusted_mem(sz=0)" )
290
+ int trusted_to_untrusted_mem (void * ctx )
291
+ {
292
+ return subprog_void_untrusted (bpf_get_current_task_btf ());
293
+ }
294
+
295
+ SEC ("tp_btf/sys_enter" )
296
+ __success
297
+ int anything_to_untrusted_mem (void * ctx )
298
+ {
299
+ /* untrusted to untrusted mem */
300
+ subprog_void_untrusted (bpf_core_cast (0 , struct task_struct ));
301
+ /* map value to untrusted mem */
302
+ subprog_void_untrusted (mem );
303
+ /* scalar to untrusted mem */
304
+ subprog_void_untrusted (0 );
305
+ /* variable offset to untrusted mem (map) */
306
+ subprog_void_untrusted ((void * )mem + off );
307
+ /* variable offset to untrusted mem (trusted) */
308
+ subprog_void_untrusted (bpf_get_current_task_btf () + off );
309
+ /* variable offset to untrusted char/enum/enum64 (map) */
310
+ subprog_char_untrusted (mem + off );
311
+ subprog_enum_untrusted ((void * )mem + off );
312
+ subprog_enum64_untrusted ((void * )mem + off );
313
+ return 0 ;
314
+ }
315
+
263
316
char _license [] SEC ("license" ) = "GPL" ;
0 commit comments