3.16.1-18 - Update valgrind-3.16.1-open-proc-self-exe.patch to handle openat

This commit is contained in:
Mark Wielaard 2021-02-07 02:45:19 +01:00
parent 4d61a87974
commit 694bfef4aa
2 changed files with 31 additions and 1 deletions

View File

@ -69,3 +69,30 @@ index 7d4b385a3..3810f7474 100644
return; return;
#endif // defined(VGO_linux) #endif // defined(VGO_linux)
diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c
index 52074149d..fcc534454 100644
--- a/coregrind/m_syswrap/syswrap-linux.c
+++ b/coregrind/m_syswrap/syswrap-linux.c
@@ -5745,6 +5745,22 @@ PRE(sys_openat)
return;
}
+ /* And for /proc/self/exe or /proc/<pid>/exe case. */
+
+ VG_(sprintf)(name, "/proc/%d/exe", VG_(getpid)());
+ if (ML_(safe_to_deref)( (void*)(Addr)ARG2, 1 )
+ && (VG_(strcmp)((HChar *)(Addr)ARG2, name) == 0
+ || VG_(strcmp)((HChar *)(Addr)ARG2, "/proc/self/exe") == 0)) {
+ sres = VG_(dup)( VG_(cl_exec_fd) );
+ SET_STATUS_from_SysRes( sres );
+ if (!sr_isError(sres)) {
+ OffT off = VG_(lseek)( sr_Res(sres), 0, VKI_SEEK_SET );
+ if (off < 0)
+ SET_STATUS_Failure( VKI_EMFILE );
+ }
+ return;
+ }
+
/* Otherwise handle normally */
*flags |= SfMayBlock;
}

View File

@ -3,7 +3,7 @@
Summary: Tool for finding memory management bugs in programs Summary: Tool for finding memory management bugs in programs
Name: %{?scl_prefix}valgrind Name: %{?scl_prefix}valgrind
Version: 3.16.1 Version: 3.16.1
Release: 17%{?dist} Release: 18%{?dist}
Epoch: 1 Epoch: 1
License: GPLv2+ License: GPLv2+
URL: http://www.valgrind.org/ URL: http://www.valgrind.org/
@ -528,6 +528,9 @@ fi
%endif %endif
%changelog %changelog
* Sat Feb 6 2021 Mark Wielaard <mjw@fedoraproject.org> - 3.16.1-18
- Update valgrind-3.16.1-open-proc-self-exe.patch to handle openat
* Sat Feb 6 2021 Mark Wielaard <mjw@fedoraproject.org> - 3.16.1-17 * Sat Feb 6 2021 Mark Wielaard <mjw@fedoraproject.org> - 3.16.1-17
- Add valgrind-3.16.1-open-proc-self-exe.patch - Add valgrind-3.16.1-open-proc-self-exe.patch