@@ -2856,7 +2856,18 @@ FILLER(execve_extra_tail_2, true) {
28562856 /* Parameter 30: egid (type: PT_GID) */
28572857 struct cred * cred = (struct cred * )_READ (task -> cred );
28582858 kgid_t egid = _READ (cred -> egid );
2859- return bpf_push_u32_to_ring (data , egid .val );
2859+ res = bpf_push_u32_to_ring (data , egid .val );
2860+ CHECK_RES (res );
2861+
2862+ if (data -> state -> tail_ctx .evt_type == PPME_SYSCALL_EXECVEAT_X ) {
2863+ return res ;
2864+ }
2865+
2866+ /* The following is valid only for PPME_SYSCALL_EXECVE_19_X */
2867+
2868+ /* Parameter 31: filename (type: PT_FSPATH) */
2869+ unsigned long filename_pointer = bpf_syscall_get_argument (data , 0 );
2870+ return bpf_val_to_ring_mem (data , filename_pointer , USER );
28602871}
28612872
28622873FILLER (sys_accept4_x , true) {
@@ -7120,7 +7131,26 @@ FILLER(sched_prog_exec_5, false) {
71207131 /* Parameter 30: egid (type: PT_GID) */
71217132 struct cred * cred = (struct cred * )_READ (task -> cred );
71227133 kgid_t egid = _READ (cred -> egid );
7123- return bpf_push_u32_to_ring (data , egid .val );
7134+ res = bpf_push_u32_to_ring (data , egid .val );
7135+ CHECK_RES (res );
7136+
7137+ /* Parameter 31: filename (type: PT_FSPATH) */
7138+ /* note: in the current implementation, this filler is called for both successful execve and
7139+ * execveat, and always generates an execve event. We use `bprm->filename` to populate the
7140+ * `filename` parameter. `bprm->filename` contains a different thing, depending on the original
7141+ * system call type and arguments provided by the user (see
7142+ * https://elixir.bootlin.com/linux/v6.17.8/source/fs/exec.c#L1422-L1448).
7143+ * At least for execve, it contains the system call's first argument, as provided by the user.
7144+ */
7145+ struct sched_process_exec_args * original_ctx = (struct sched_process_exec_args * )data -> ctx ;
7146+ #ifdef BPF_SUPPORTS_RAW_TRACEPOINTS
7147+ struct linux_binprm * bprm = original_ctx -> bprm ;
7148+ unsigned long filename_pointer = (unsigned long )_READ (bprm -> filename );
7149+ #else
7150+ unsigned long filename_offset = (unsigned long )original_ctx -> filename & 0xFFFF ;
7151+ unsigned long filename_pointer = (unsigned long )original_ctx + filename_offset ;
7152+ #endif
7153+ return bpf_val_to_ring_mem (data , filename_pointer , KERNEL );
71247154}
71257155
71267156#ifdef CAPTURE_SCHED_PROC_FORK
0 commit comments