From: Mark W. <ma...@so...> - 2025-07-19 21:08:58
|
https://sourceware.org/cgit/valgrind/commit/?id=769ca880912f26f3b6033bfe08e7417580b02c25 commit 769ca880912f26f3b6033bfe08e7417580b02c25 Author: Mark Wielaard <ma...@kl...> Date: Sat Jul 19 22:19:08 2025 +0200 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. Diff: --- 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 280b1ccb6a..7ac86fbbc0 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 d1cfdad69a..552fceee8d 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 */ |