import CS valgrind-3.21.0-7.el9

This commit is contained in:
eabdullin 2023-09-21 20:38:27 +00:00
parent fcb1ed14e0
commit 560baefc46
14 changed files with 654 additions and 293 deletions

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/valgrind-3.19.0.tar.bz2 SOURCES/valgrind-3.21.0.tar.bz2

View File

@ -1 +1 @@
294c341b421b4d9534e42e8125f509c148f48c17 SOURCES/valgrind-3.19.0.tar.bz2 817d769743d278b5d07526e85115082054e9bf9c SOURCES/valgrind-3.21.0.tar.bz2

View File

@ -35,19 +35,6 @@ index 1b7842b..e211eec 100644
if HAVE_DLINFO_RTLD_DI_TLS_MODID if HAVE_DLINFO_RTLD_DI_TLS_MODID
getoff_@VGCONF_ARCH_PRI@_@VGCONF_OS@_LDADD = $(LDADD) -ldl getoff_@VGCONF_ARCH_PRI@_@VGCONF_OS@_LDADD = $(LDADD) -ldl
endif endif
diff --git a/cachegrind/Makefile.am b/cachegrind/Makefile.am
index f572741..1c07e50 100644
--- a/cachegrind/Makefile.am
+++ b/cachegrind/Makefile.am
@@ -27,7 +27,7 @@ cg_merge_SOURCES = cg_merge.c
cg_merge_CPPFLAGS = $(AM_CPPFLAGS_PRI)
cg_merge_CFLAGS = $(AM_CFLAGS_PRI) -fstack-protector-strong
cg_merge_CCASFLAGS = $(AM_CCASFLAGS_PRI)
-cg_merge_LDFLAGS = $(AM_CFLAGS_PRI)
+cg_merge_LDFLAGS = $(AM_CFLAGS_PRI) -Wl,-z,now
# If there is no secondary platform, and the platforms include x86-darwin,
# then the primary platform must be x86-darwin. Hence:
if ! VGCONF_HAVE_PLATFORM_SEC
diff --git a/coregrind/Makefile.am b/coregrind/Makefile.am diff --git a/coregrind/Makefile.am b/coregrind/Makefile.am
index 3c73210..fb6b7bb 100644 index 3c73210..fb6b7bb 100644
--- a/coregrind/Makefile.am --- a/coregrind/Makefile.am

View File

@ -35,19 +35,6 @@ index 56cc5ef..1b7842b 100644
getoff_@VGCONF_ARCH_PRI@_@VGCONF_OS@_CCASFLAGS = $(AM_CCASFLAGS_PRI) getoff_@VGCONF_ARCH_PRI@_@VGCONF_OS@_CCASFLAGS = $(AM_CCASFLAGS_PRI)
getoff_@VGCONF_ARCH_PRI@_@VGCONF_OS@_LDFLAGS = $(AM_CFLAGS_PRI) @LIB_UBSAN@ getoff_@VGCONF_ARCH_PRI@_@VGCONF_OS@_LDFLAGS = $(AM_CFLAGS_PRI) @LIB_UBSAN@
if HAVE_DLINFO_RTLD_DI_TLS_MODID if HAVE_DLINFO_RTLD_DI_TLS_MODID
diff --git a/cachegrind/Makefile.am b/cachegrind/Makefile.am
index f8447a1..f572741 100644
--- a/cachegrind/Makefile.am
+++ b/cachegrind/Makefile.am
@@ -25,7 +25,7 @@ bin_PROGRAMS = cg_merge
cg_merge_SOURCES = cg_merge.c
cg_merge_CPPFLAGS = $(AM_CPPFLAGS_PRI)
-cg_merge_CFLAGS = $(AM_CFLAGS_PRI)
+cg_merge_CFLAGS = $(AM_CFLAGS_PRI) -fstack-protector-strong
cg_merge_CCASFLAGS = $(AM_CCASFLAGS_PRI)
cg_merge_LDFLAGS = $(AM_CFLAGS_PRI)
# If there is no secondary platform, and the platforms include x86-darwin,
diff --git a/configure.ac b/configure.ac diff --git a/configure.ac b/configure.ac
index f8c798b..ccc8f52 100755 index f8c798b..ccc8f52 100755
--- a/configure.ac --- a/configure.ac

View File

@ -1,25 +0,0 @@
commit 947388eb043ea1c44b37df94046e1eee790ad776
Author: Mike Crowe <mac@mcrowe.com>
Date: Mon Sep 9 14:16:16 2019 +0100
Intercept strncmp for glibc ld.so v2.28+
In glibc 5aad5f617892e75d91d4c8fb7594ff35b610c042 (first released in
v2.28) a call to strncmp was added to dl-load.c:is_dst. This causes
valgrind to complain about glibc's highly-optimised strncmp performing
sixteen-byte reads on short strings in ld.so. Let's intercept strncmp in
ld.so too so we use valgrind's simple version to avoid this problem.
diff --git a/shared/vg_replace_strmem.c b/shared/vg_replace_strmem.c
index 3b42b3a87..5396e83be 100644
--- a/shared/vg_replace_strmem.c
+++ b/shared/vg_replace_strmem.c
@@ -710,6 +710,8 @@ static inline void my_exit ( int x )
STRNCMP(VG_Z_LIBC_SONAME, __GI_strncmp)
STRNCMP(VG_Z_LIBC_SONAME, __strncmp_sse2)
STRNCMP(VG_Z_LIBC_SONAME, __strncmp_sse42)
+ STRNCMP(VG_Z_LD_LINUX_SO_2, strncmp)
+ STRNCMP(VG_Z_LD_LINUX_X86_64_SO_2, strncmp)
#elif defined(VGO_freebsd)
STRNCMP(VG_Z_LIBC_SONAME, strncmp)

View File

@ -1,231 +0,0 @@
From 42ca1c480a5bca408a54c6a24d2be2c081d121ac Mon Sep 17 00:00:00 2001
From: Andreas Arnez <arnez@linux.ibm.com>
Date: Thu, 19 May 2022 13:54:06 +0200
Subject: [PATCH] Bug 454040 - Add intercept for memmem on s390x
Since memcheck may report false positives in an optimized version of memmem on
s390x, add an intercept for memmem on s390x platforms.
---
shared/vg_replace_strmem.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/shared/vg_replace_strmem.c b/shared/vg_replace_strmem.c
index 5396e83be..d28e74206 100644
--- a/shared/vg_replace_strmem.c
+++ b/shared/vg_replace_strmem.c
@@ -103,6 +103,7 @@
20430 WMEMCHR
20440 WCSNLEN
20450 WSTRNCMP
+ 20460 MEMMEM
*/
#if defined(VGO_solaris)
@@ -1785,6 +1786,41 @@ static inline void my_exit ( int x )
#endif
+/*---------------------- memmem ----------------------*/
+
+#define MEMMEM(soname, fnname) \
+ void* VG_REPLACE_FUNCTION_EZU(20460,soname,fnname) \
+ (const void* haystack, SizeT hlen, const void* needle, SizeT nlen); \
+ void* VG_REPLACE_FUNCTION_EZU(20460,soname,fnname) \
+ (const void* haystack, SizeT hlen, const void* needle, SizeT nlen) \
+ { \
+ const HChar* h = haystack; \
+ const HChar* n = needle; \
+ \
+ /* If the needle is the empty string, match immediately. */ \
+ if (nlen == 0) return CONST_CAST(void *,h); \
+ \
+ HChar n0 = n[0]; \
+ \
+ for (; hlen >= nlen; hlen--, h++) { \
+ if (h[0] != n0) continue; \
+ \
+ UWord i; \
+ for (i = 1; i < nlen; i++) { \
+ if (n[i] != h[i]) \
+ break; \
+ } \
+ if (i == nlen) \
+ return CONST_CAST(HChar *,h); \
+ \
+ } \
+ return NULL; \
+ }
+
+#if defined(VGP_s390x_linux)
+ MEMMEM(VG_Z_LIBC_SONAME, memmem)
+#endif
+
/*---------------------- strpbrk ----------------------*/
--
2.31.1
From 4d675f309bcd2d4e9e2b9e6f4aba30f85116bb9b Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Thu, 19 May 2022 18:08:40 -0400
Subject: [PATCH] Add memmem memcheck tests
---
memcheck/tests/Makefile.am | 3 ++
memcheck/tests/filter_memmem | 5 ++
memcheck/tests/memmem.c | 81 ++++++++++++++++++++++++++++++++
memcheck/tests/memmem.stderr.exp | 2 +
memcheck/tests/memmem.vgtest | 3 ++
5 files changed, 94 insertions(+)
create mode 100755 memcheck/tests/filter_memmem
create mode 100644 memcheck/tests/memmem.c
create mode 100644 memcheck/tests/memmem.stderr.exp
create mode 100644 memcheck/tests/memmem.vgtest
diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am
index eb9487272..4d181c1ac 100644
--- a/memcheck/tests/Makefile.am
+++ b/memcheck/tests/Makefile.am
@@ -79,6 +79,7 @@ dist_noinst_SCRIPTS = \
filter_strchr \
filter_varinfo3 \
filter_memcheck \
+ filter_memmem \
filter_overlaperror \
filter_malloc_free \
filter_sized_delete
@@ -220,6 +221,7 @@ EXTRA_DIST = \
memalign2.stderr.exp memalign2.vgtest \
memcmptest.stderr.exp memcmptest.stderr.exp2 \
memcmptest.stdout.exp memcmptest.vgtest \
+ memmem.stderr.exp memmem.vgtest \
mempool.stderr.exp mempool.vgtest \
mempool2.stderr.exp mempool2.vgtest \
metadata.stderr.exp metadata.stdout.exp metadata.vgtest \
@@ -417,6 +419,7 @@ check_PROGRAMS = \
malloc_usable malloc1 malloc2 malloc3 manuel1 manuel2 manuel3 \
match-overrun \
memalign_test memalign2 memcmptest mempool mempool2 mmaptest \
+ memmem \
mismatches new_override metadata \
nanoleak_supp nanoleak2 new_nothrow \
noisy_child \
diff --git a/memcheck/tests/filter_memmem b/memcheck/tests/filter_memmem
new file mode 100755
index 000000000..f4a40b2d1
--- /dev/null
+++ b/memcheck/tests/filter_memmem
@@ -0,0 +1,5 @@
+#! /bin/sh
+
+# Too many memmem implementations and overrides.
+# So just keep the main file lines.
+./filter_stderr "$@" | grep " main (memmem.c:"
diff --git a/memcheck/tests/memmem.c b/memcheck/tests/memmem.c
new file mode 100644
index 000000000..d627076e3
--- /dev/null
+++ b/memcheck/tests/memmem.c
@@ -0,0 +1,81 @@
+#define _GNU_SOURCE
+#include <assert.h>
+#include <string.h>
+#include <stdlib.h>
+
+/* mallocs an mem block and fills it with A. A needs to be a zero
+ terminated string. The A string chars, minus the terminating zero
+ are copied into the returned mem block. */
+static void *
+create_mem (const char *a)
+{
+ size_t len = strlen (a);
+ void *mem = malloc (len);
+ memcpy (mem, a, len);
+ return mem;
+}
+
+int
+main ()
+{
+ char *haystack;
+ char *needle;
+
+ haystack = create_mem ("a");
+ needle = create_mem ("a");
+ assert (memmem (haystack, 0, needle, 0) == haystack);
+ assert (memmem (haystack, 1, needle, 0) == haystack);
+ assert (memmem (haystack, 0, needle, 1) == NULL);
+ assert (memmem (haystack, 1, needle, 1) == haystack);
+ free (haystack);
+ free (needle);
+
+ haystack = create_mem ("abc");
+ needle = create_mem ("bc");
+ assert (memmem (haystack, 3, needle, 0) == haystack);
+ assert (memmem (haystack, 3, needle, 2) == haystack + 1);
+ assert (memmem (haystack + 1, 2, needle, 2) == haystack + 1);
+ assert (memmem (haystack + 2, 1, needle, 2) == NULL);
+ free (haystack);
+ free (needle);
+
+ haystack = create_mem ("abcabcabc");
+ needle = create_mem ("bca");
+ assert (memmem (haystack, 9, needle, 3) == haystack + 1);
+ free (haystack);
+ free (needle);
+
+ haystack = create_mem ("abcabcabc");
+ needle = create_mem ("bcad");
+ assert (memmem (haystack, 9, needle, 4) == NULL);
+ free (haystack);
+ free (needle);
+
+ haystack = create_mem ("xxxxxxxxxxxxxxxxxABC");
+ needle = create_mem ("ABCD");
+ assert (memmem (haystack, 20, needle, 2) == haystack + 17);
+ assert (memmem (haystack + 3, 17, needle, 2) == haystack + 17);
+ assert (memmem (haystack + 15, 5, needle, 2) == haystack + 17);
+ assert (memmem (haystack, 20, needle, 3) == haystack + 17);
+ assert (memmem (haystack + 3, 17, needle, 3) == haystack + 17);
+ assert (memmem (haystack + 15, 5, needle, 3) == haystack + 17);
+ assert (memmem (haystack, 20, needle, 4) == NULL);
+ assert (memmem (haystack + 3, 5, needle, 4) == NULL);
+ assert (memmem (haystack + 15, 5, needle, 4) == NULL);
+ free (haystack);
+ free (needle);
+
+ haystack = malloc (1);
+ needle = create_mem ("a");
+ assert (memmem (haystack, 1, needle, 1) == NULL);
+ free (haystack);
+ free (needle);
+
+ haystack = create_mem ("A");
+ needle = malloc (1);
+ assert (memmem (haystack, 1, needle, 1) == NULL);
+ free (haystack);
+ free (needle);
+
+ return 0;
+}
diff --git a/memcheck/tests/memmem.stderr.exp b/memcheck/tests/memmem.stderr.exp
new file mode 100644
index 000000000..b4612fbd4
--- /dev/null
+++ b/memcheck/tests/memmem.stderr.exp
@@ -0,0 +1,2 @@
+ by 0x........: main (memmem.c:70)
+ by 0x........: main (memmem.c:76)
diff --git a/memcheck/tests/memmem.vgtest b/memcheck/tests/memmem.vgtest
new file mode 100644
index 000000000..6d12895df
--- /dev/null
+++ b/memcheck/tests/memmem.vgtest
@@ -0,0 +1,3 @@
+prog: memmem
+vgopts: -q
+stderr_filter: filter_memmem
--
2.18.4

View File

@ -0,0 +1,123 @@
From e97f7a6cf2315908fb0a9b900f1de87a155c9df1 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Sun, 14 May 2023 23:34:05 +0200
Subject: [PATCH] Add --with-gdbscripts-dir=PATH configure option
Currently the gdb valgrind scripts are installed under VG_LIBDIR
which is normally pkglibexecdir which is likely not in the default
gdb safe-path (a list of directories from which it is safe to
auto-load files). So users will have to add the directory to their
.gdbinit file.
This patch adds a --with-gdbscripts-dir=PATH configure option that
sets VG_GDBSCRIPTS_DIR to the given PATH (${libexecdir}/valgrind if
not given).
Use VG_GDBSCRIPTS_DIR as gdbscriptsdir to install the valgrind-monitor
python files and pass it with CPPFLAGS when building vg_preloaded.c
and vgdb.c to use instead of VG_LIBDIR.
---
configure.ac | 11 +++++++++++
coregrind/Makefile.am | 15 ++++++++++-----
coregrind/vg_preloaded.c | 2 +-
coregrind/vgdb.c | 2 +-
4 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/configure.ac b/configure.ac
index 15fbf5ea2..223ab4529 100755
--- a/configure.ac
+++ b/configure.ac
@@ -1198,6 +1198,17 @@ AC_MSG_RESULT([$xcodedir])
AC_DEFINE_UNQUOTED(XCODE_DIR, "$xcodedir", [xcode sdk include directory])
AC_SUBST(XCODE_DIR, [$xcodedir])])
+#----------------------------------------------------------------------------
+# Where to install gdb scripts, defaults to VG_LIBDIR (pkglibexecdir)
+#----------------------------------------------------------------------------
+AC_MSG_CHECKING([where gdb scripts are installed])
+AC_ARG_WITH(gdbscripts-dir,
+ [ --with-gdbscripts-dir=PATH Specify path to install gdb scripts],
+ [gdbscriptsdir=${withval}],
+ [gdbscriptsdir=${libexecdir}/valgrind])
+AC_MSG_RESULT([$gdbscriptsdir])
+AC_SUBST(VG_GDBSCRIPTS_DIR, [$gdbscriptsdir])
+
#----------------------------------------------------------------------------
# Libc and suppressions
#----------------------------------------------------------------------------
diff --git a/coregrind/Makefile.am b/coregrind/Makefile.am
index 553211782..64d593b08 100644
--- a/coregrind/Makefile.am
+++ b/coregrind/Makefile.am
@@ -101,7 +101,8 @@
vgdb_SOURCES += vgdb-invoker-freebsd.c
endif
-vgdb_CPPFLAGS = $(AM_CPPFLAGS_PRI)
+vgdb_CPPFLAGS = $(AM_CPPFLAGS_PRI) \
+ -DVG_GDBSCRIPTS_DIR="\"@VG_GDBSCRIPTS_DIR@\""
vgdb_CFLAGS = $(AM_CFLAGS_PRI) $(LTO_CFLAGS) -fstack-protector-strong
vgdb_CCASFLAGS = $(AM_CCASFLAGS_PRI)
vgdb_LDFLAGS = $(AM_CFLAGS_PRI) @LIB_UBSAN@ -Wl,-z,now
@@ -626,7 +627,8 @@
vgpreload_core_@VGCONF_ARCH_PRI@_@VGCONF_OS@_so_SOURCES = vg_preloaded.c
vgpreload_core_@VGCONF_ARCH_PRI@_@VGCONF_OS@_so_CPPFLAGS = \
- $(AM_CPPFLAGS_@VGCONF_PLATFORM_PRI_CAPS@)
+ $(AM_CPPFLAGS_@VGCONF_PLATFORM_PRI_CAPS@) \
+ -DVG_GDBSCRIPTS_DIR="\"@VG_GDBSCRIPTS_DIR@\""
vgpreload_core_@VGCONF_ARCH_PRI@_@VGCONF_OS@_so_CFLAGS = \
$(AM_CFLAGS_PSO_@VGCONF_PLATFORM_PRI_CAPS@)
vgpreload_core_@VGCONF_ARCH_PRI@_@VGCONF_OS@_so_LDFLAGS = \
@@ -634,7 +636,8 @@
if VGCONF_HAVE_PLATFORM_SEC
vgpreload_core_@VGCONF_ARCH_SEC@_@VGCONF_OS@_so_SOURCES = vg_preloaded.c
vgpreload_core_@VGCONF_ARCH_SEC@_@VGCONF_OS@_so_CPPFLAGS = \
- $(AM_CPPFLAGS_@VGCONF_PLATFORM_SEC_CAPS@)
+ $(AM_CPPFLAGS_@VGCONF_PLATFORM_SEC_CAPS@) \
+ -DVG_GDBSCRIPTS_DIR="\"@VG_GDBSCRIPTS_DIR@\""
vgpreload_core_@VGCONF_ARCH_SEC@_@VGCONF_OS@_so_CFLAGS = \
$(AM_CFLAGS_PSO_@VGCONF_PLATFORM_SEC_CAPS@)
vgpreload_core_@VGCONF_ARCH_SEC@_@VGCONF_OS@_so_LDFLAGS = \
@@ -766,8 +769,10 @@
# so as to make sure these get copied into the install tree
vglibdir = $(pkglibexecdir)
vglib_DATA = $(GDBSERVER_XML_FILES)
-vglib_DATA += m_gdbserver/valgrind-monitor.py
-vglib_DATA += m_gdbserver/valgrind-monitor-def.py
+
+gdbscriptsdir = @VG_GDBSCRIPTS_DIR@
+gdbscripts_DATA = m_gdbserver/valgrind-monitor.py
+gdbscripts_DATA += m_gdbserver/valgrind-monitor-def.py
# so as to make sure these get copied into the tarball
EXTRA_DIST += $(GDBSERVER_XML_FILES)
diff --git a/coregrind/vg_preloaded.c b/coregrind/vg_preloaded.c
index d6e05898c..bff76b81b 100644
--- a/coregrind/vg_preloaded.c
+++ b/coregrind/vg_preloaded.c
@@ -61,7 +61,7 @@
.popsection \n\
");
-DEFINE_GDB_PY_SCRIPT(VG_LIBDIR "/valgrind-monitor.py")
+DEFINE_GDB_PY_SCRIPT(VG_GDBSCRIPTS_DIR "/valgrind-monitor.py")
#endif
#if defined(VGO_linux) || defined(VGO_solaris) || defined(VGO_freebsd)
diff --git a/coregrind/vgdb.c b/coregrind/vgdb.c
index 8ec424077..a449b86e0 100644
--- a/coregrind/vgdb.c
+++ b/coregrind/vgdb.c
@@ -1984,7 +1984,7 @@ void usage(void)
" -h --help shows this message\n"
" The GDB python code defining GDB front end valgrind commands is:\n %s\n"
" To get help from the Valgrind gdbserver, use vgdb help\n"
-"\n", vgdb_prefix_default(), VG_LIBDIR "/valgrind-monitor.py"
+"\n", vgdb_prefix_default(), VG_GDBSCRIPTS_DIR "/valgrind-monitor.py"
);
invoker_restrictions_msg();
}
--
2.40.0

View File

@ -0,0 +1,12 @@
diff --git a/callgrind/callgrind_control.in b/callgrind/callgrind_control.in
index 083ffa29f..eb50c16ad 100644
--- a/callgrind/callgrind_control.in
+++ b/callgrind/callgrind_control.in
@@ -22,7 +22,6 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
-use strict;
use warnings;
use File::Basename;

View File

@ -0,0 +1,22 @@
diff --git a/shared/vg_replace_strmem.c b/shared/vg_replace_strmem.c
index b32f13f76..464e8d4ca 100644
--- a/shared/vg_replace_strmem.c
+++ b/shared/vg_replace_strmem.c
@@ -1128,7 +1128,7 @@ static inline void my_exit ( int x )
MEMMOVE_OR_MEMCPY(20181, soname, fnname, 0)
#define MEMCPY(soname, fnname) \
- MEMMOVE_OR_MEMCPY(20180, soname, fnname, 1)
+ MEMMOVE_OR_MEMCPY(20180, soname, fnname, 0) /* See KDE bug #402833 */
#if defined(VGO_linux)
/* For older memcpy we have to use memmove-like semantics and skip
@@ -1714,8 +1714,6 @@ static inline void my_exit ( int x )
RECORD_COPY(len); \
if (len == 0) \
return dst; \
- if (is_overlap(dst, src, len, len)) \
- RECORD_OVERLAP_ERROR("memcpy_chk", dst, src, len); \
if ( dst > src ) { \
d = (HChar *)dst + len - 1; \
s = (const HChar *)src + len - 1; \

View File

@ -0,0 +1,73 @@
From 56f1bd12c92806fd18337ba4cd3c0a8d714d0e94 Mon Sep 17 00:00:00 2001
From: Andreas Arnez <arnez@linux.ibm.com>
Date: Thu, 15 Jun 2023 17:24:53 +0200
Subject: [PATCH] Bug 470978 - s390x: Link the tools with -Wl,--s390-pgste
Programs that require the PGSTE mode to be enabled may currently fail
under Valgrind. In particular this affects qemu-kvm.
While it is also possible to enable the PGSTE mode globally with
sysctl vm.allocate_psgte=1
the problem can more easily be prevented by linking the Valgrind tools
with -Wl,--s390-pgste. Add a configure check if the linker supports this,
and activate the flag if it does.
To verify the intended result, the following shell command can be used to
list the executables having this flag set:
find . -type f -perm -u+x -execdir \
/bin/sh -c 'readelf -lW $0 2>/dev/null | grep PGSTE' {} \; -print
---
Makefile.tool.am | 2 +-
configure.ac | 20 ++++++++++++++++++++
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/Makefile.tool.am b/Makefile.tool.am
index df9502913..4ce6d5ab0 100644
--- a/Makefile.tool.am
+++ b/Makefile.tool.am
@@ -78,7 +78,7 @@ TOOL_LDFLAGS_ARM64_LINUX = \
$(TOOL_LDFLAGS_COMMON_LINUX) @FLAG_M64@
TOOL_LDFLAGS_S390X_LINUX = \
- $(TOOL_LDFLAGS_COMMON_LINUX) @FLAG_M64@
+ $(TOOL_LDFLAGS_COMMON_LINUX) @FLAG_M64@ @FLAG_S390_PGSTE@
TOOL_LDFLAGS_X86_DARWIN = \
$(TOOL_LDFLAGS_COMMON_DARWIN) -arch i386
diff --git a/configure.ac b/configure.ac
index 0cf84a1c0..1d4164a7d 100755
--- a/configure.ac
+++ b/configure.ac
@@ -3096,6 +3096,26 @@ AC_SUBST([FLAG_NO_BUILD_ID], [""])
fi
CFLAGS=$safe_CFLAGS
+# On s390x, if the linker supports -Wl,--s390-pgste, then we build the
+# tools with that flag. This enables running programs that need it, such
+# as qemu-kvm.
+if test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX; then
+AC_MSG_CHECKING([if the linker accepts -Wl,--s390-pgste])
+safe_CFLAGS=$CFLAGS
+CFLAGS="-Wl,--s390-pgste"
+
+AC_LINK_IFELSE(
+[AC_LANG_PROGRAM([ ], [return 0;])],
+[
+ AC_SUBST([FLAG_S390_PGSTE], ["-Wl,--s390-pgste"])
+ AC_MSG_RESULT([yes])
+], [
+ AC_SUBST([FLAG_S390_PGSTE], [""])
+ AC_MSG_RESULT([no])
+])
+CFLAGS=$safe_CFLAGS
+fi
+
# does the ppc assembler support "mtocrf" et al?
AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
--
2.40.1

View File

@ -0,0 +1,167 @@
From b904112d7084227f8d6fab322bc360a8a6240a51 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Thu, 1 Jun 2023 16:10:56 +0200
Subject: [PATCH] memcheck: Handle Err_ReallocSizeZero in MC_(eq_Error)
When an realloc size zero error is emitted MC_(eq_Error) is called to
see if the errors can be deduplicated. This crashed since
Err_ReallocSizeZero wasn't handled. Handle it like Err_Free.
Also add a testcase for this case and test with both
--realloc-zero-bytes-frees=yes and
--realloc-zero-bytes-frees=no.
Which will report a different number of errors.
https://bugs.kde.org/show_bug.cgi?id=470520
---
memcheck/mc_errors.c | 1 +
memcheck/tests/Makefile.am | 7 +++++++
memcheck/tests/realloc_size_zero_again.c | 15 +++++++++++++++
.../realloc_size_zero_again_no.stderr.exp | 18 ++++++++++++++++++
.../realloc_size_zero_again_no.stdout.exp | 0
.../tests/realloc_size_zero_again_no.vgtest | 2 ++
.../realloc_size_zero_again_yes.stderr.exp | 18 ++++++++++++++++++
.../realloc_size_zero_again_yes.stdout.exp | 0
.../tests/realloc_size_zero_again_yes.vgtest | 2 ++
9 files changed, 63 insertions(+)
create mode 100644 memcheck/tests/realloc_size_zero_again.c
create mode 100644 memcheck/tests/realloc_size_zero_again_no.stderr.exp
create mode 100644 memcheck/tests/realloc_size_zero_again_no.stdout.exp
create mode 100644 memcheck/tests/realloc_size_zero_again_no.vgtest
create mode 100644 memcheck/tests/realloc_size_zero_again_yes.stderr.exp
create mode 100644 memcheck/tests/realloc_size_zero_again_yes.stdout.exp
create mode 100644 memcheck/tests/realloc_size_zero_again_yes.vgtest
diff --git a/memcheck/mc_errors.c b/memcheck/mc_errors.c
index 00d6ec301..65210a220 100644
--- a/memcheck/mc_errors.c
+++ b/memcheck/mc_errors.c
@@ -1041,6 +1041,7 @@ Bool MC_(eq_Error) ( VgRes res, const Error* e1, const Error* e2 )
case Err_IllegalMempool:
case Err_Overlap:
case Err_Cond:
+ case Err_ReallocSizeZero:
return True;
case Err_FishyValue:
diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am
index 71c38acba..5a17fd35d 100644
--- a/memcheck/tests/Makefile.am
+++ b/memcheck/tests/Makefile.am
@@ -291,8 +291,14 @@ EXTRA_DIST = \
realloc_size_zero.vgtest \
realloc_size_zero_yes.stderr.exp realloc_size_zero_yes.stdout.exp \
realloc_size_zero_yes.vgtest \
+ realloc_size_zero_again_yes.stderr.exp \
+ realloc_size_zero_again_yes.stdout.exp \
+ realloc_size_zero_again_yes.vgtest \
realloc_size_zero_no.stderr.exp realloc_size_zero_no.stdout.exp \
realloc_size_zero_no.vgtest \
+ realloc_size_zero_again_no.stderr.exp \
+ realloc_size_zero_again_no.stdout.exp \
+ realloc_size_zero_again_no.vgtest \
realloc_size_zero_off.stderr.exp realloc_size_zero_off.stdout.exp \
realloc_size_zero_off.vgtest \
realloc_size_zero_mismatch.stderr.exp \
@@ -459,6 +465,7 @@ check_PROGRAMS = \
posix_memalign \
post-syscall \
realloc_size_zero realloc_size_zero_mismatch \
+ realloc_size_zero_again \
realloc1 realloc2 realloc3 \
recursive-merge \
resvn_stack \
diff --git a/memcheck/tests/realloc_size_zero_again.c b/memcheck/tests/realloc_size_zero_again.c
new file mode 100644
index 000000000..782d4bde5
--- /dev/null
+++ b/memcheck/tests/realloc_size_zero_again.c
@@ -0,0 +1,15 @@
+#include <stdlib.h>
+
+int
+main ()
+{
+ char *p = malloc (1024);
+ for (int i = 3; i >= 0; i--)
+ for (int j = 0; j <= 3; j++)
+ {
+ char *q = realloc (p, i * j * 512);
+ p = q;
+ }
+
+ free (p);
+}
diff --git a/memcheck/tests/realloc_size_zero_again_no.stderr.exp b/memcheck/tests/realloc_size_zero_again_no.stderr.exp
new file mode 100644
index 000000000..b9c061d1a
--- /dev/null
+++ b/memcheck/tests/realloc_size_zero_again_no.stderr.exp
@@ -0,0 +1,18 @@
+realloc() with size 0
+ at 0x........: realloc (vg_replace_malloc.c:...)
+ ...
+ Address 0x........ is 0 bytes inside a block of size 1,024 alloc'd
+ at 0x........: malloc (vg_replace_malloc.c:...)
+ ...
+
+ERROR SUMMARY: 7 errors from 1 contexts (suppressed: 0 from 0)
+
+7 errors in context 1 of 1:
+realloc() with size 0
+ at 0x........: realloc (vg_replace_malloc.c:...)
+ ...
+ Address 0x........ is 0 bytes inside a block of size 1,024 alloc'd
+ at 0x........: malloc (vg_replace_malloc.c:...)
+ ...
+
+ERROR SUMMARY: 7 errors from 1 contexts (suppressed: 0 from 0)
diff --git a/memcheck/tests/realloc_size_zero_again_no.stdout.exp b/memcheck/tests/realloc_size_zero_again_no.stdout.exp
new file mode 100644
index 000000000..e69de29bb
diff --git a/memcheck/tests/realloc_size_zero_again_no.vgtest b/memcheck/tests/realloc_size_zero_again_no.vgtest
new file mode 100644
index 000000000..f1757b6c1
--- /dev/null
+++ b/memcheck/tests/realloc_size_zero_again_no.vgtest
@@ -0,0 +1,2 @@
+prog: realloc_size_zero_again
+vgopts: -q -s --realloc-zero-bytes-frees=no
diff --git a/memcheck/tests/realloc_size_zero_again_yes.stderr.exp b/memcheck/tests/realloc_size_zero_again_yes.stderr.exp
new file mode 100644
index 000000000..d40aa2455
--- /dev/null
+++ b/memcheck/tests/realloc_size_zero_again_yes.stderr.exp
@@ -0,0 +1,18 @@
+realloc() with size 0
+ at 0x........: realloc (vg_replace_malloc.c:...)
+ ...
+ Address 0x........ is 0 bytes inside a block of size 1,024 alloc'd
+ at 0x........: malloc (vg_replace_malloc.c:...)
+ ...
+
+ERROR SUMMARY: 5 errors from 1 contexts (suppressed: 0 from 0)
+
+5 errors in context 1 of 1:
+realloc() with size 0
+ at 0x........: realloc (vg_replace_malloc.c:...)
+ ...
+ Address 0x........ is 0 bytes inside a block of size 1,024 alloc'd
+ at 0x........: malloc (vg_replace_malloc.c:...)
+ ...
+
+ERROR SUMMARY: 5 errors from 1 contexts (suppressed: 0 from 0)
diff --git a/memcheck/tests/realloc_size_zero_again_yes.stdout.exp b/memcheck/tests/realloc_size_zero_again_yes.stdout.exp
new file mode 100644
index 000000000..e69de29bb
diff --git a/memcheck/tests/realloc_size_zero_again_yes.vgtest b/memcheck/tests/realloc_size_zero_again_yes.vgtest
new file mode 100644
index 000000000..215392ed6
--- /dev/null
+++ b/memcheck/tests/realloc_size_zero_again_yes.vgtest
@@ -0,0 +1,2 @@
+prog: realloc_size_zero_again
+vgopts: -q -s --realloc-zero-bytes-frees=yes
--
2.40.1

View File

@ -0,0 +1,105 @@
From 21f7a2af2805a02a144c81f12895c134f4a171a3 Mon Sep 17 00:00:00 2001
From: Andreas Arnez <arnez@linux.ibm.com>
Date: Mon, 22 May 2023 19:49:08 +0200
Subject: [PATCH 2/2] Bug 470132 - s390x: Increase test coverage for VGM
Add more tests for the VGM instruction, to verify the fix for the VGM
wrap-around case. Also test setting unused bits in the I2 and I3 fields,
to check that Valgrind ignores them as it should.
---
none/tests/s390x/vec2.c | 44 ++++++++++++++++++++++++++++++++
none/tests/s390x/vec2.stdout.exp | 20 +++++++++++++++
2 files changed, 64 insertions(+)
diff --git a/none/tests/s390x/vec2.c b/none/tests/s390x/vec2.c
index 73b04dee4..c473a2a9a 100644
--- a/none/tests/s390x/vec2.c
+++ b/none/tests/s390x/vec2.c
@@ -301,6 +301,49 @@ static void test_all_fp_int_conversions()
#undef TEST_EXEC
#undef TEST_GENERATE
+/* -- Vector generate mask -- */
+
+#define TEST_GENERATE(insn, i2, i3, m4) \
+ static void test_vgm_##i2##_##i3##_##m4(void) \
+ { \
+ ulong_v out = vec_ini; \
+ __asm__("vgm %[out]," #i2 "," #i3 "," #m4 : [out] "+v"(out) : :); \
+ printf("\t%016lx %016lx\n", out[0], out[1]); \
+ }
+
+#define TEST_EXEC(insn, i2, i3, m4) \
+ do { \
+ puts(#insn " " #i2 "," #i3 "," #m4); \
+ test_vgm_##i2##_##i3##_##m4(); \
+ } while (0)
+
+#define INSNS \
+ XTEST(vgmb, 2, 1, 0); \
+ XTEST(vgmb, 0xf7, 0x30, 0); \
+ XTEST(vgmb, 0, 0, 0); \
+ XTEST(vgmh, 3, 2, 1); \
+ XTEST(vgmh, 15, 15, 1); \
+ XTEST(vgmf, 4, 3, 2); \
+ XTEST(vgmf, 16, 17, 2); \
+ XTEST(vgmg, 55, 63, 3); \
+ XTEST(vgmg, 43, 55, 3); \
+ XTEST(vgmg, 63, 2, 3);
+
+#define XTEST TEST_GENERATE
+INSNS
+#undef XTEST
+
+static void test_all_generate_mask()
+{
+#define XTEST TEST_EXEC
+ INSNS
+#undef XTEST
+}
+
+#undef INSNS
+#undef TEST_EXEC
+#undef TEST_GENERATE
+
int main()
{
@@ -310,5 +353,6 @@ int main()
test_all_double_bitshifts();
test_all_int_fp_conversions();
test_all_fp_int_conversions();
+ test_all_generate_mask();
return 0;
}
diff --git a/none/tests/s390x/vec2.stdout.exp b/none/tests/s390x/vec2.stdout.exp
index b32cbe1bc..2c9ac21c1 100644
--- a/none/tests/s390x/vec2.stdout.exp
+++ b/none/tests/s390x/vec2.stdout.exp
@@ -166,3 +166,23 @@ vcsfp 0
vcsfp 8
00ffffff - - -
00000004 - - -
+vgmb 2,1,0
+ ffffffffffffffff ffffffffffffffff
+vgmb 0xf7,0x30,0
+ 8181818181818181 8181818181818181
+vgmb 0,0,0
+ 8080808080808080 8080808080808080
+vgmh 3,2,1
+ ffffffffffffffff ffffffffffffffff
+vgmh 15,15,1
+ 0001000100010001 0001000100010001
+vgmf 4,3,2
+ ffffffffffffffff ffffffffffffffff
+vgmf 16,17,2
+ 0000c0000000c000 0000c0000000c000
+vgmg 55,63,3
+ 00000000000001ff 00000000000001ff
+vgmg 43,55,3
+ 00000000001fff00 00000000001fff00
+vgmg 63,2,3
+ e000000000000001 e000000000000001
--
2.40.1

View File

@ -0,0 +1,99 @@
From 70ef4417837b690755feede0088331a28b102c65 Mon Sep 17 00:00:00 2001
From: Andreas Arnez <arnez@linux.ibm.com>
Date: Mon, 22 May 2023 18:57:35 +0200
Subject: [PATCH 1/2] Bug 470132 - s390x: Fix the wrap-around case in VGM
Valgrind's implementation of VGM is incomplete:
* It doesn't support generating a wrap-around bit mask. Such a mask
should result when the ending bit position is smaller than the starting
bit position. Valgrind runs into an assertion failure instead.
* It doesn't ignore unused bits in the I2 and I3 fields of the
instruction, as it should.
Fix this by re-implementing the main logic in s390_irgen_VGM().
---
VEX/priv/guest_s390_toIR.c | 57 +++++++++++++++-----------------------
1 file changed, 22 insertions(+), 35 deletions(-)
diff --git a/VEX/priv/guest_s390_toIR.c b/VEX/priv/guest_s390_toIR.c
index 11dda41ef..d9d746c38 100644
--- a/VEX/priv/guest_s390_toIR.c
+++ b/VEX/priv/guest_s390_toIR.c
@@ -16388,50 +16388,37 @@ s390_irgen_VGBM(UChar v1, UShort i2, UChar m3 __attribute__((unused)))
static const HChar *
s390_irgen_VGM(UChar v1, UShort i2, UChar m3)
{
- UChar from = (i2 & 0xff00) >> 8;
- UChar to = (i2 & 0x00ff);
- ULong value = 0UL;
- IRType type = s390_vr_get_type(m3);
- vassert(from <= to);
-
- UChar maxIndex = 0;
- switch (type) {
- case Ity_I8:
- maxIndex = 7;
- break;
- case Ity_I16:
- maxIndex = 15;
- break;
- case Ity_I32:
- maxIndex = 31;
- break;
- case Ity_I64:
- maxIndex = 63;
- break;
- default:
- vpanic("s390_irgen_VGM: unknown type");
- }
-
- for(UChar index = from; index <= to; index++) {
- value |= (1ULL << (maxIndex - index));
- }
-
- IRExpr *fillValue;
- switch (type) {
- case Ity_I8:
+ s390_insn_assert("vgm", m3 <= 3);
+
+ UChar max_idx = (8 << m3) - 1;
+ UChar from = max_idx & (i2 >> 8);
+ UChar to = max_idx & i2;
+ ULong all_one = (1ULL << max_idx << 1) - 1;
+ ULong value = (all_one >> from) ^ (all_one >> to >> 1);
+
+ /* In case of wrap-around we now have a value that needs inverting:
+ to from
+ V V
+ 00000111111111110000000000000000 */
+ if (to < from)
+ value ^= all_one;
+
+ IRExpr* fillValue;
+ switch (m3) {
+ case 0:
fillValue = mkU8(value);
break;
- case Ity_I16:
+ case 1:
fillValue = mkU16(value);
break;
- case Ity_I32:
+ case 2:
fillValue = mkU32(value);
break;
- case Ity_I64:
+ case 3:
fillValue = mkU64(value);
break;
default:
- vpanic("s390_irgen_VGM: unknown type");
+ vpanic("s390_irgen_VGM: unknown element size");
}
s390_vr_fill(v1, fillValue);
--
2.40.1

View File

@ -2,14 +2,12 @@
Summary: Dynamic analysis tools to detect memory or thread bugs and profile Summary: Dynamic analysis tools to detect memory or thread bugs and profile
Name: %{?scl_prefix}valgrind Name: %{?scl_prefix}valgrind
Version: 3.19.0 Version: 3.21.0
Release: 3%{?dist} Release: 7%{?dist}
Epoch: 1 Epoch: 1
License: GPLv2+ License: GPLv2+
URL: https://www.valgrind.org/ URL: https://www.valgrind.org/
# Only necessary for RHEL, will be ignored on Fedora
# Are we building for a Software Collection? # Are we building for a Software Collection?
%{?scl:%global is_scl 1} %{?scl:%global is_scl 1}
%{!?scl:%global is_scl 0} %{!?scl:%global is_scl 0}
@ -85,11 +83,30 @@ Patch3: valgrind-3.16.0-some-stack-protector.patch
# Add some -Wl,z,now. # Add some -Wl,z,now.
Patch4: valgrind-3.16.0-some-Wl-z-now.patch Patch4: valgrind-3.16.0-some-Wl-z-now.patch
# KDE#434764 # iconv_open causes ld.so v2.28+ to execute optimised strncmp # Workaround https://bugs.kde.org/show_bug.cgi?id=402833
Patch5: valgrind-3.19.0-ld-so-strncmp.patch # by disabling overlap checking for memcpy
Patch5: valgrind-3.21.0-no-memcpy-replace-check.patch
# KDE#454040 s390x: False-positive memcheck:cond in memmem on arch13 systems # Add --with-gdbscripts-dir=PATH configure option
Patch6: valgrind-3.19.0-s390x-memmem.patch # https://bugs.kde.org/show_bug.cgi?id=469768
Patch6: valgrind-3.21.0-Add-with-gdbscripts-dir.patch
# Can't run callgrind_control with valgrind 3.21.0 because of perl errors
# https://bugs.kde.org/show_bug.cgi?id=470121
Patch8: valgrind-3.21.0-callgrind_control-no-strict.patch
# Multiple realloc zero errors crash in MC_(eq_Error)
# https://bugs.kde.org/show_bug.cgi?id=470520
Patch9: valgrind-3.21.0-realloc-again.patch
# s390x: Assertion failure on VGM instruction
# https://bugs.kde.org/show_bug.cgi?id=470132
Patch10: valgrind-3.21.0-vgm.patch
Patch11: valgrind-3.21.0-vgm-tests.patch
# s390x: Valgrind cannot start qemu-kvm when "sysctl vm.allocate_pgste=0"
# https://bugs.kde.org/show_bug.cgi?id=470978
Patch12: valgrind-3.21.0-pgste.patch
BuildRequires: make BuildRequires: make
BuildRequires: glibc-devel BuildRequires: glibc-devel
@ -231,6 +248,13 @@ Valgrind User Manual for details.
%patch5 -p1 %patch5 -p1
%patch6 -p1 %patch6 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%build %build
# LTO triggers undefined symbols in valgrind. Valgrind has a --enable-lto # LTO triggers undefined symbols in valgrind. Valgrind has a --enable-lto
# configure time option, but that doesn't seem to help. # configure time option, but that doesn't seem to help.
@ -299,7 +323,8 @@ export LDFLAGS
%configure \ %configure \
--with-mpicc=%{mpiccpath} \ --with-mpicc=%{mpiccpath} \
%{only_arch} \ %{only_arch} \
GDB=%{_bindir}/gdb GDB=%{_bindir}/gdb \
--with-gdbscripts-dir=%{_datadir}/gdb/auto-load
%make_build %make_build
@ -417,6 +442,8 @@ echo ===============END TESTING===============
# Was disabled in %%install to prevent debuginfo stripping. # Was disabled in %%install to prevent debuginfo stripping.
%attr(0755,root,root) %{_libexecdir}/valgrind/vgpreload*-%{valarch}-*so %attr(0755,root,root) %{_libexecdir}/valgrind/vgpreload*-%{valarch}-*so
%{_mandir}/man1/* %{_mandir}/man1/*
%{_datadir}/gdb/auto-load/valgrind-monitor.py
%{_datadir}/gdb/auto-load/valgrind-monitor-def.py
%files devel %files devel
%dir %{_includedir}/valgrind %dir %{_includedir}/valgrind
@ -459,6 +486,21 @@ fi
%endif %endif
%changelog %changelog
* Fri Jun 23 2023 Mark Wielaard <mjw@redhat.com> - 3.21.0-7
- Add valgrind-3.21.0-callgrind_control-no-strict.patch
- Add valgrind-3.21.0-realloc-again.patch
- Update valgrind-3.21.0-no-memcpy-replace-check.patch (memcpy_chk)
- Add valgrind-3.21.0-vgm.patch and valgrind-3.21.0-vgm-tests.patch
- Add valgrind-3.21.0-pgste.patch
* Tue May 16 2023 Alexandra Hájková <ahajkova@redhat.com> - 3.21.0-3
- Add valgrind-3.21.0-Add-with-gdbscripts-dir.patch
* Fri May 5 2023 Mark Wielaard <mjw@redhat.com> - 3.21.0-2
- Upgrade to upstream 3.21.0
- Remove upstreamed patches
- Add valgrind-3.21.0-no-memcpy-replace-check.patch
* Wed May 25 2022 Mark Wielaard <mjw@redhat.com> - 3.19.0-3 * Wed May 25 2022 Mark Wielaard <mjw@redhat.com> - 3.19.0-3
- Add valgrind-3.19.0-s390x-memmem.patch - Add valgrind-3.19.0-s390x-memmem.patch
- Add valgrind-3.19.0-ld-so-strncmp.patch - Add valgrind-3.19.0-ld-so-strncmp.patch