3.24.0-6 - More VALGRIND_3_24_BRANCH patches

Resolves: #RHEL-82799
valgrind: ld.so memcmp interceptor required on x86_64

- 0015-ppc-test_dfp2-build-fix-for-GCC-15.patch
- 0016-syswrap-generic-Emit-pp_ExeContext-after-the-file-de.patch
- 0017-add_hardwired_spec-for-ld-linux-x86-64.so.2-memcmp.patch
- 0018-gdbserver_tests-filter-out-new-Missing-rpms-message.patch
This commit is contained in:
Mark Wielaard 2025-03-18 18:42:07 +01:00
parent 4a9ebe2ce2
commit a0a1fcbd2d
5 changed files with 290 additions and 1 deletions

View File

@ -0,0 +1,70 @@
From 9e4b5f1cc9f09f61fd3fb0e5687d0fc5ef39f15d Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Wed, 15 Jan 2025 16:27:12 +0100
Subject: [PATCH] ppc test_dfp2 build fix for GCC 15
GCC 15 defaults to C23 which changes the meaning of unprototyped
functions, those declaring no arguments with (). Causing some errors:
test_dfp2.c:412:26: error: initialization of 'void (*)(void)' from incompatible pointer type 'void (*)(int)' [-Wincompatible-pointer-types]
412 | { &_test_dscri, "dscri", dfp_2args_x1, 20, LONG_TEST, ">>", True},
| ^
test_dfp2.c:412:26: note: (near initialization for 'dfp_two_arg_tests[0].test_func')
test_dfp2.c:110:13: note: '_test_dscri' declared here
110 | static void _test_dscri (int shift)
| ^~~~~~~~~~~
test_dfp2.c:664:17: error: assignment to 'test_func_t' {aka 'void (*)(void)'} from incompatible pointer type 'test_func_main_t' {aka 'void (*)(int)'} [-Wincompatible-pointer-types]
664 | while ((func = all_tests[i].test_category)) {
| ^
test_dfp2.c:237:16: note: 'test_func_t' declared here
237 | typedef void (*test_func_t)();
| ^~~~~~~~~~~
test_dfp2.c:238:16: note: 'test_func_main_t' declared here
238 | typedef void (*test_func_main_t)(int);
| ^~~~~~~~~~~~~~~~
test_dfp2.c:667:8: error: too many arguments to function 'func'; expected 0, have 1
667 | (*func)(has_vsx);
| ~^~~~~~ ~~~~~~~
Fix this by just explicitly compiling that code with -std=gnu99.
---
none/tests/ppc32/Makefile.am | 4 +++-
none/tests/ppc64/Makefile.am | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/none/tests/ppc32/Makefile.am b/none/tests/ppc32/Makefile.am
index 187cab74f763..7727876fdf66 100644
--- a/none/tests/ppc32/Makefile.am
+++ b/none/tests/ppc32/Makefile.am
@@ -129,8 +129,10 @@ test_isa_2_06_part3_CFLAGS = $(AM_CFLAGS) -Winline -Wall -O -g -mregnames $(VSX_
test_dfp1_CFLAGS = $(AM_CFLAGS) -Winline -Wall -O -g -mregnames $(DFP_FLAG) \
@FLAG_M32@ $(BUILD_FLAGS_DFP)
+# Explicitly use -std=gnu99 because the meaning of void (*test_func_t)()
+# changed in c23, causing incompatible-pointer-types errors.
test_dfp2_CFLAGS = $(AM_CFLAGS) -Winline -Wall -O -g -mregnames $(DFP_FLAG) \
- @FLAG_M32@ $(BUILD_FLAGS_DFP)
+ @FLAG_M32@ $(BUILD_FLAGS_DFP) -std=gnu99
test_dfp3_CFLAGS = $(AM_CFLAGS) -Winline -Wall -O -g -mregnames $(DFP_FLAG) \
@FLAG_M32@ $(BUILD_FLAGS_DFP)
test_dfp4_CFLAGS = $(AM_CFLAGS) -Winline -Wall -O -g -mregnames $(DFP_FLAG) \
diff --git a/none/tests/ppc64/Makefile.am b/none/tests/ppc64/Makefile.am
index f8eab9fc00b2..98a14b434bc4 100644
--- a/none/tests/ppc64/Makefile.am
+++ b/none/tests/ppc64/Makefile.am
@@ -190,8 +190,10 @@ test_isa_2_06_part3_CFLAGS = $(AM_CFLAGS) -Winline -Wall -O -g -mregnames $(VSX_
test_dfp1_CFLAGS = $(AM_CFLAGS) -Winline -Wall -O -g -mregnames $(DFP_FLAG) \
@FLAG_M64@ $(BUILD_FLAGS_DFP)
+# Explicitly use -std=gnu99 because the meaning of void (*test_func_t)()
+# changed in c23, causing incompatible-pointer-types errors.
test_dfp2_CFLAGS = $(AM_CFLAGS) -Winline -Wall -O -g -mregnames $(DFP_FLAG) \
- @FLAG_M64@ $(BUILD_FLAGS_DFP)
+ @FLAG_M64@ $(BUILD_FLAGS_DFP) -std=gnu99
test_dfp3_CFLAGS = $(AM_CFLAGS) -Winline -Wall -O -g -mregnames $(DFP_FLAG) \
@FLAG_M64@ $(BUILD_FLAGS_DFP)
test_dfp4_CFLAGS = $(AM_CFLAGS) -Winline -Wall -O -g -mregnames $(DFP_FLAG) \
--
2.47.1

View File

@ -0,0 +1,57 @@
From ec7335142384ec9da66871036803b96319b590eb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alexandra=20H=C3=A1jkov=C3=A1?= <ahajkova@redhat.com>
Date: Mon, 3 Mar 2025 06:14:08 -0500
Subject: [PATCH 16/18] syswrap-generic: Emit pp_ExeContext after the file
descriptor backtrace
Adjust use_after_close test for the change.
(cherry picked from commit 838dc01d2c42f7f22785c771bd74bc4e595da444)
---
coregrind/m_syswrap/syswrap-generic.c | 2 +-
none/tests/use_after_close.stderr.exp | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c
index 1d80d09288ed..5222bcefe11b 100644
--- a/coregrind/m_syswrap/syswrap-generic.c
+++ b/coregrind/m_syswrap/syswrap-generic.c
@@ -1179,6 +1179,7 @@ void fd_pp_Error (const Error *err)
}
VG_(emit)("%sFile descriptor %d %s%s\n", whatpre, nce->fd,
error_string, whatpost);
+ VG_(pp_ExeContext)(where);
/* If the file descriptor was never created we won't have
where_closed and where_opened. Only print them in a
use after close case. */
@@ -1190,7 +1191,6 @@ void fd_pp_Error (const Error *err)
VG_(emit)("%sOriginally opened%s\n", auxpre, auxpost);
VG_(pp_ExeContext)(nce->where_opened);
}
- VG_(pp_ExeContext)(where);
} else {
vg_assert2 (False, "Unknown error kind: %d",
VG_(get_error_kind)(err));
diff --git a/none/tests/use_after_close.stderr.exp b/none/tests/use_after_close.stderr.exp
index 1ef31c6551eb..75a8d6672949 100644
--- a/none/tests/use_after_close.stderr.exp
+++ b/none/tests/use_after_close.stderr.exp
@@ -1,13 +1,13 @@
bad
File descriptor 3 was closed already
+ at 0x........: write (in /...libc...)
+ by 0x........: main
Previously closed
at 0x........: close (in /...libc...)
by 0x........: main
Originally opened
at 0x........: dup (in /...libc...)
by 0x........: main
- at 0x........: write (in /...libc...)
- by 0x........: main
File descriptor 7 was never created
at 0x........: write (in /...libc...)
by 0x........: main
--
2.48.1

View File

@ -0,0 +1,101 @@
From 2c17a8a3e865816ee48e7f78148bbc7240c2a38c Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Wed, 12 Mar 2025 13:57:19 +0100
Subject: [PATCH 17/18] add_hardwired_spec for ld-linux-x86-64.so.2 memcmp
With RPATH processing ld.so compiled for x86-64-v3 uses an optimized
avx2 memcmp (bcmp) which causes (false postive) memcheck invalid reads
of size 32 warnings.
Fix this my adding a hardwire spec with a simpler memcmp for
ld-linux-x86-64.so.2.
https://bugs.kde.org/show_bug.cgi?id=501348
Authored-by: Florian Weimer <fweimer@redhat.com>
(cherry picked from commit 9ffdeb4927b8505cc5a9ea54f608f4972166bb0e)
---
NEWS | 1 +
coregrind/m_redir.c | 9 +++++++++
coregrind/m_trampoline.S | 19 +++++++++++++++++++
coregrind/pub_core_trampoline.h | 1 +
4 files changed, 30 insertions(+)
diff --git a/NEWS b/NEWS
index 7f9e005c59f4..fe225c666c77 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,7 @@ The following bugs have been fixed or resolved on this branch.
498317 FdBadUse is not a valid CoreError type in a suppression
even though it's generated by --gen-suppressions=yes
498143 False positive on EVIOCGRAB ioctl
+501348 glibc built with -march=x86-64-v3 does not work due to ld.so memcmp
To see details of a given bug, visit
https://bugs.kde.org/show_bug.cgi?id=XXXXXX
diff --git a/coregrind/m_redir.c b/coregrind/m_redir.c
index f9e8d8801a19..64ebea3b6304 100644
--- a/coregrind/m_redir.c
+++ b/coregrind/m_redir.c
@@ -1425,6 +1425,15 @@ void VG_(redir_initialise) ( void )
NULL
# else
complain_about_stripped_glibc_ldso
+# endif
+ );
+ add_hardwired_spec(
+ "ld-linux-x86-64.so.2", "memcmp",
+ (Addr)&VG_(amd64_linux_REDIR_FOR_memcmp),
+# ifndef GLIBC_MANDATORY_STRLEN_REDIRECT
+ NULL
+# else
+ complain_about_stripped_glibc_ldso
# endif
);
}
diff --git a/coregrind/m_trampoline.S b/coregrind/m_trampoline.S
index e897963be21a..27f1b35d2b08 100644
--- a/coregrind/m_trampoline.S
+++ b/coregrind/m_trampoline.S
@@ -241,6 +241,25 @@ VG_(amd64_linux_REDIR_FOR_strcmp):
ret
.size VG_(amd64_linux_REDIR_FOR_strcmp), .-VG_(amd64_linux_REDIR_FOR_strcmp)
+.global VG_(amd64_linux_REDIR_FOR_memcmp)
+.type VG_(amd64_linux_REDIR_FOR_memcmp), @function
+VG_(amd64_linux_REDIR_FOR_memcmp):
+ xorl %ecx, %ecx
+ jmp 2f
+1:
+ movzbl (%rdi, %rcx), %eax
+ movzbl (%rsi, %rcx), %r8d
+ addq $1, %rcx
+ subl %r8d, %eax
+ jne 3f
+2:
+ cmpq %rcx, %rdx
+ jne 1b
+ xorl %eax, %eax
+3:
+ ret
+.size VG_(amd64_linux_REDIR_FOR_memcmp), .-VG_(amd64_linux_REDIR_FOR_memcmp)
+
.global VG_(amd64_linux_REDIR_FOR_index)
.type VG_(amd64_linux_REDIR_FOR_index), @function
VG_(amd64_linux_REDIR_FOR_index):
diff --git a/coregrind/pub_core_trampoline.h b/coregrind/pub_core_trampoline.h
index d0bd6b859742..3d2f7e9f32b7 100644
--- a/coregrind/pub_core_trampoline.h
+++ b/coregrind/pub_core_trampoline.h
@@ -82,6 +82,7 @@ extern Addr VG_(amd64_linux_REDIR_FOR_vtime);
extern Addr VG_(amd64_linux_REDIR_FOR_vgetcpu);
extern UInt VG_(amd64_linux_REDIR_FOR_strlen)( void* );
extern Int VG_(amd64_linux_REDIR_FOR_strcmp)( void*, void* );
+extern Int VG_(amd64_linux_REDIR_FOR_memcmp)( void*, void*, SizeT );
extern Char* VG_(amd64_linux_REDIR_FOR_index) ( const Char*, Int );
#endif
--
2.48.1

View File

@ -0,0 +1,45 @@
From 7b2806871f15977db3a64a59f70d48f55ba3228e Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Thu, 16 Jan 2025 17:30:37 +0100
Subject: [PATCH 18/18] gdbserver_tests: filter out new Missing rpms message
As seen on the fedora 40 s390x tester. GDB now might output something
like:
Missing rpms, try: dnf --enablerepo='*debug*' install glibc-debuginfo-2.39-33.fc40.s390x
Filter those messages out to get zero fail test results again.
(cherry picked from commit 090f8ce59b5f3d3ec39e032ee5e9524ce4f51a44)
---
gdbserver_tests/filter_gdb.in | 1 +
gdbserver_tests/filter_memcheck_monitor.in | 1 +
2 files changed, 2 insertions(+)
diff --git a/gdbserver_tests/filter_gdb.in b/gdbserver_tests/filter_gdb.in
index 094ea933ec51..2bef9f3ee57b 100755
--- a/gdbserver_tests/filter_gdb.in
+++ b/gdbserver_tests/filter_gdb.in
@@ -265,6 +265,7 @@ s/^0x........ in \(\w\+ (\)/\1/
# delete any missing debuginfo messages
/^Missing debuginfo.*/d
+/^Missing rpms.*/d
EOF
diff --git a/gdbserver_tests/filter_memcheck_monitor.in b/gdbserver_tests/filter_memcheck_monitor.in
index 6e8a49a303ba..e407e7b92158 100755
--- a/gdbserver_tests/filter_memcheck_monitor.in
+++ b/gdbserver_tests/filter_memcheck_monitor.in
@@ -31,6 +31,7 @@ $dir/filter_vgdb |
$SED -e '/Cannot access memory at address 0x......../d' \
-e '/^[1-9][0-9]* \.\.\/sysdeps\/powerpc\/powerpc32\/dl-start\.S: No such file or directory\./d' \
-e '/^Missing separate debuginfo/d' \
+ -e '/^Missing rpms/d' \
-e '/^Try: zypper install -C/d' \
-e 's/Test 3: FAIL: expected si_code==2, not 128/Test 3: PASS/' \
-e 's/in use at exit: [0-9][0-9,]* bytes in [0-9][0-9]* blocks/in use at exit: ... bytes in ... blocks/' \
--
2.48.1

View File

@ -3,7 +3,7 @@
Summary: Dynamic analysis tools to detect memory or thread bugs and profile
Name: %{?scl_prefix}valgrind
Version: 3.24.0
Release: 4%{?dist}
Release: 6%{?dist}
Epoch: 1
# This ignores licenses that are only found in the test or perf sources
@ -100,6 +100,11 @@ Patch15: 0011-Add-open_tree-move_mount-fsopen-fsconfig-fsmount-fsp.patch
Patch16: 0012-Recognize-new-DWARF5-DW_LANG-constants.patch
Patch17: 0013-Bug-498317-FdBadUse-is-not-a-valid-CoreError-type-in.patch
Patch18: 0014-linux-support-EVIOCGRAB-ioctl.patch
Patch19: 0015-ppc-test_dfp2-build-fix-for-GCC-15.patch
Patch20: 0016-syswrap-generic-Emit-pp_ExeContext-after-the-file-de.patch
Patch21: 0017-add_hardwired_spec-for-ld-linux-x86-64.so.2-memcmp.patch
Patch22: 0018-gdbserver_tests-filter-out-new-Missing-rpms-message.patch
BuildRequires: make
BuildRequires: glibc-devel
@ -290,6 +295,10 @@ Valgrind User Manual for details.
%patch -P16 -p1
%patch -P17 -p1
%patch -P18 -p1
%patch -P19 -p1
%patch -P20 -p1
%patch -P21 -p1
%patch -P22 -p1
%build
# LTO triggers undefined symbols in valgrind. But valgrind has a
@ -529,6 +538,13 @@ echo ===============END TESTING===============
%endif
%changelog
* Tue Mar 18 2025 Mark Wielaard <mjw@redhat.com> - 3.24.0-6
- More VALGRIND_3_24_BRANCH patches
0015-ppc-test_dfp2-build-fix-for-GCC-15.patch
0016-syswrap-generic-Emit-pp_ExeContext-after-the-file-de.patch
0017-add_hardwired_spec-for-ld-linux-x86-64.so.2-memcmp.patch
0018-gdbserver_tests-filter-out-new-Missing-rpms-message.patch
* Wed Feb 26 2025 Mark Wielaard <mjw@redhat.com> - 3.24.0-4
- Split main valgrind package into several subpackages:
- valgrind now contains just the core tools.