From 769ca880912f26f3b6033bfe08e7417580b02c25 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Sat, 19 Jul 2025 22:19:08 +0200 Subject: [PATCH] Just set filename ARG to handle /proc/self/exe in open, openat and openat2 This simplifies the logic a little and makes reasoning about how the PRE handler works slightly simpler. --- coregrind/m_syswrap/syswrap-generic.c | 3 +-- coregrind/m_syswrap/syswrap-linux.c | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c index 280b1ccb6..7ac86fbbc 100644 --- a/coregrind/m_syswrap/syswrap-generic.c +++ b/coregrind/m_syswrap/syswrap-generic.c @@ -4692,8 +4692,7 @@ PRE(sys_open) if (proc_self_exe) { // do the syscall with VG_(resolved_exename) - SET_STATUS_from_SysRes(VG_(do_syscall3)(SYSNO, (Word)VG_(resolved_exename), ARG2, ARG3)); - return; + ARG1 = (Word)VG_(resolved_exename); } #endif // defined(VGO_linux) diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index d1cfdad69..552fceee8 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -6094,8 +6094,7 @@ no_client_write: if (proc_self_exe) { // do the syscall with VG_(resolved_exename) - SET_STATUS_from_SysRes(VG_(do_syscall4)(SYSNO, ARG1, (Word)VG_(resolved_exename), ARG3, ARG4)); - return; + ARG2 = (Word)VG_(resolved_exename); } /* Otherwise handle normally */ @@ -14095,8 +14094,7 @@ PRE(sys_openat2) if (proc_self_exe) { // do the syscall with VG_(resolved_exename) - SET_STATUS_from_SysRes(VG_(do_syscall4)(SYSNO, ARG1, (Word)VG_(resolved_exename), ARG3, ARG4)); - return; + ARG2 = (Word)VG_(resolved_exename); } /* Otherwise handle normally */ -- 2.47.2