From 13964be68c5b5424e9fc3d1ecc5c68585b352512 Mon Sep 17 00:00:00 2001 From: DistroBaker Date: Sat, 6 Feb 2021 22:32:41 +0000 Subject: [PATCH] Merged update from upstream sources This is an automated DistroBaker update from upstream sources. If you do not know what this is about or would like to opt out, contact the OSCI team. Source: https://src.fedoraproject.org/rpms/valgrind.git#4d61a8797443b47dcda7d1383cedfd511979438c --- valgrind-3.16.1-open-proc-self-exe.patch | 71 ++++++++++++++++++++++++ valgrind.spec | 10 +++- 2 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 valgrind-3.16.1-open-proc-self-exe.patch diff --git a/valgrind-3.16.1-open-proc-self-exe.patch b/valgrind-3.16.1-open-proc-self-exe.patch new file mode 100644 index 0000000..7525f8a --- /dev/null +++ b/valgrind-3.16.1-open-proc-self-exe.patch @@ -0,0 +1,71 @@ +diff --git a/coregrind/m_syswrap/priv_syswrap-generic.h b/coregrind/m_syswrap/priv_syswrap-generic.h +index 4717abac6..c50b31399 100644 +--- a/coregrind/m_syswrap/priv_syswrap-generic.h ++++ b/coregrind/m_syswrap/priv_syswrap-generic.h +@@ -106,6 +106,10 @@ extern Bool + ML_(handle_auxv_open)(SyscallStatus *status, const HChar *filename, + int flags); + ++extern Bool ++ML_(handle_self_exe_open)(SyscallStatus *status, const HChar *filename, ++ int flags); ++ + /* Helper function for generic mprotect and linux pkey_mprotect. */ + extern void handle_sys_mprotect (ThreadId tid, SyscallStatus *status, + Addr *addr, SizeT *len, Int *prot); +diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c +index 7d4b385a3..3810f7474 100644 +--- a/coregrind/m_syswrap/syswrap-generic.c ++++ b/coregrind/m_syswrap/syswrap-generic.c +@@ -4078,6 +4078,38 @@ Bool ML_(handle_auxv_open)(SyscallStatus *status, const HChar *filename, + } + #endif // defined(VGO_linux) || defined(VGO_solaris) + ++#if defined(VGO_linux) ++Bool ML_(handle_self_exe_open)(SyscallStatus *status, const HChar *filename, ++ int flags) ++{ ++ HChar name[30]; // large enough for /proc//exe ++ ++ if (!ML_(safe_to_deref)((const void *) filename, 1)) ++ return False; ++ ++ /* Opening /proc//exe or /proc/self/exe? */ ++ VG_(sprintf)(name, "/proc/%d/exe", VG_(getpid)()); ++ if (!VG_STREQ(filename, name) && !VG_STREQ(filename, "/proc/self/exe")) ++ return False; ++ ++ /* Allow to open the file only for reading. */ ++ if (flags & (VKI_O_WRONLY | VKI_O_RDWR)) { ++ SET_STATUS_Failure(VKI_EACCES); ++ return True; ++ } ++ ++ SysRes 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 True; ++} ++#endif // defined(VGO_linux) ++ + PRE(sys_open) + { + if (ARG2 & VKI_O_CREAT) { +@@ -4119,8 +4151,10 @@ PRE(sys_open) + } + } + +- /* Handle also the case of /proc/self/auxv or /proc//auxv. */ +- if (ML_(handle_auxv_open)(status, (const HChar *)(Addr)ARG1, ARG2)) ++ /* Handle also the case of /proc/self/auxv or /proc//auxv ++ or /proc/self/exe or /proc//exe. */ ++ if (ML_(handle_auxv_open)(status, (const HChar *)(Addr)ARG1, ARG2) ++ || ML_(handle_self_exe_open)(status, (const HChar *)(Addr)ARG1, ARG2)) + return; + #endif // defined(VGO_linux) + diff --git a/valgrind.spec b/valgrind.spec index 5a33e04..957665f 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -3,7 +3,7 @@ Summary: Tool for finding memory management bugs in programs Name: %{?scl_prefix}valgrind Version: 3.16.1 -Release: 16%{?dist} +Release: 17%{?dist} Epoch: 1 License: GPLv2+ URL: http://www.valgrind.org/ @@ -147,6 +147,10 @@ Patch22: valgrind-3.16.1-dwarf5.patch # RHBZ#1909548 shmctl(IPC_STAT) doesn't set shm_nattch on aarch64 Patch23: valgrind-3.16.0-shmctl.patch +# KDE#140178 open("/proc/self/exe", ...); doesn't quite work +# RHBZ#1925786 valgrind appears to only interject readlink on /proc/self/exe +Patch24: valgrind-3.16.1-open-proc-self-exe.patch + BuildRequires: make BuildRequires: glibc-devel @@ -299,6 +303,7 @@ Valgrind User Manual for details. %patch21 -p1 %patch22 -p1 %patch23 -p1 +%patch24 -p1 %build # LTO triggers undefined symbols in valgrind. Valgrind has a --enable-lto @@ -523,6 +528,9 @@ fi %endif %changelog +* Sat Feb 6 2021 Mark Wielaard - 3.16.1-17 +- Add valgrind-3.16.1-open-proc-self-exe.patch + * Wed Feb 3 2021 Mark Wielaard - 3.16.1-16 - Add valgrind-3.16.0-shmctl.patch