File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -539,6 +539,33 @@ def bpf_get_smp_processor_id_emitter(
539539 return result , ir .IntType (32 )
540540
541541
542+ @HelperHandlerRegistry .register ("uid" )
543+ def bpf_get_current_uid_gid_emitter (
544+ call ,
545+ map_ptr ,
546+ module ,
547+ builder ,
548+ func ,
549+ local_sym_tab = None ,
550+ struct_sym_tab = None ,
551+ map_sym_tab = None ,
552+ ):
553+ """
554+ Emit LLVM IR for bpf_get_current_uid_gid helper function call.
555+ """
556+ helper_id = ir .Constant (ir .IntType (64 ), BPFHelperID .BPF_GET_CURRENT_UID_GID .value )
557+ fn_type = ir .FunctionType (ir .IntType (64 ), [], var_arg = False )
558+ fn_ptr_type = ir .PointerType (fn_type )
559+ fn_ptr = builder .inttoptr (helper_id , fn_ptr_type )
560+ result = builder .call (fn_ptr , [], tail = False )
561+
562+ # Extract the lower 32 bits (UID) using bitwise AND with 0xFFFFFFFF
563+ # TODO: return both UID and GID if we end up needing GID somewhere
564+ mask = ir .Constant (ir .IntType (64 ), 0xFFFFFFFF )
565+ pid = builder .and_ (result , mask )
566+ return pid , ir .IntType (64 )
567+
568+
542569def handle_helper_call (
543570 call ,
544571 module ,
You can’t perform that action at this time.
0 commit comments