@@ -3416,18 +3416,16 @@ int BPF_KPROBE(trace_mmap_alert)
34163416 if (!evaluate_scope_filters (& p ))
34173417 return 0 ;
34183418
3419- // Load the arguments given to the mmap syscall (which eventually invokes this function)
3420- syscall_data_t * sys = & p .task_info -> syscall_data ;
3421- if (!p .task_info -> syscall_traced || sys -> id != SYSCALL_MMAP )
3419+ if (p .event -> context .syscall != SYSCALL_MMAP )
34223420 return 0 ;
34233421
3424- int prot = sys -> args . args [ 2 ] ;
3425-
3422+ struct pt_regs * task_regs = get_current_task_pt_regs () ;
3423+ int prot = get_syscall_arg3 ( p . event -> task , task_regs , false);
34263424 if ((prot & (VM_WRITE | VM_EXEC )) == (VM_WRITE | VM_EXEC )) {
34273425 u32 alert = ALERT_MMAP_W_X ;
3428- int fd = sys -> args . args [ 4 ] ;
3429- void * addr = ( void * ) sys -> args . args [ 0 ] ;
3430- size_t len = sys -> args . args [ 1 ] ;
3426+ void * addr = ( void * ) get_syscall_arg1 ( p . event -> task , task_regs , false) ;
3427+ size_t len = get_syscall_arg2 ( p . event -> task , task_regs , false) ;
3428+ int fd = get_syscall_arg5 ( p . event -> task , task_regs , false) ;
34313429 int prev_prot = 0 ;
34323430 file_info_t file_info = {.pathname_p = NULL };
34333431 if (fd >= 0 ) {
@@ -3562,18 +3560,18 @@ int BPF_KPROBE(trace_security_file_mprotect)
35623560 if (!init_program_data (& p , ctx , SECURITY_FILE_MPROTECT ))
35633561 return 0 ;
35643562
3565- // Load the arguments given to the mprotect syscall (which eventually invokes this function)
3566- syscall_data_t * sys = & p .task_info -> syscall_data ;
3567- if (!p .task_info -> syscall_traced ||
3568- (sys -> id != SYSCALL_MPROTECT && sys -> id != SYSCALL_PKEY_MPROTECT ))
3563+ if (p .event -> context .syscall != SYSCALL_MPROTECT &&
3564+ p .event -> context .syscall != SYSCALL_PKEY_MPROTECT )
35693565 return 0 ;
35703566
35713567 struct vm_area_struct * vma = (struct vm_area_struct * ) PT_REGS_PARM1 (ctx );
35723568 unsigned long reqprot = PT_REGS_PARM2 (ctx );
35733569 unsigned long prev_prot = get_vma_flags (vma );
35743570 struct file * file = (struct file * ) BPF_CORE_READ (vma , vm_file );
3575- void * addr = (void * ) sys -> args .args [0 ];
3576- size_t len = sys -> args .args [1 ];
3571+
3572+ struct pt_regs * task_regs = get_current_task_pt_regs ();
3573+ void * addr = (void * ) get_syscall_arg1 (p .event -> task , task_regs , false);
3574+ size_t len = get_syscall_arg2 (p .event -> task , task_regs , false);
35773575
35783576 if (evaluate_scope_filters (& p )) {
35793577 file_info = get_file_info (file );
@@ -3585,8 +3583,8 @@ int BPF_KPROBE(trace_security_file_mprotect)
35853583 save_to_submit_buf (& p .event -> args_buf , & addr , sizeof (void * ), 4 );
35863584 save_to_submit_buf (& p .event -> args_buf , & len , sizeof (size_t ), 5 );
35873585
3588- if (sys -> id == SYSCALL_PKEY_MPROTECT ) {
3589- int pkey = sys -> args . args [ 3 ] ;
3586+ if (p . event -> context . syscall == SYSCALL_PKEY_MPROTECT ) {
3587+ int pkey = get_syscall_arg4 ( p . event -> task , task_regs , false) ;
35903588 save_to_submit_buf (& p .event -> args_buf , & pkey , sizeof (int ), 6 );
35913589 }
35923590
0 commit comments