valgrind/0021-Avoid-dev-inode-check-on-btrfs-with-sanity-level-3.patch
Mark Wielaard ba355a609a 3.23.0-4 - Add upstream VALGRIND_3_23_BRANCH patches
0001-Prepare-NEWS-for-branch-3.23-fixes.patch
  0002-486180-MIPS-VexGuestArchState-has-no-member-named-gu.patch
  0003-Bug-486293-memccpy-false-positives.patch
  0004-Bug-486569-linux-inotify_init-syscall-wrapper-missin.patch
  0005-aarch64-frinta-and-frinta-vector-instructions.patch
  0006-mips-skip-using-shared-syscall-numbers-for-mips32.patch
  0007-Fix-uninitialized-err-in-handle_extension.patch
  0008-Avoid-use-of-guest_IP_AT_SYSCALL-in-handle_extension.patch
  0009-s390x-Minor-fixes-in-extension-s390x.c.patch
  0010-Bug-453044-gbserver_tests-failures-in-aarch64.patch
  0011-Linux-regtest-reallocarray-needs-malloc.h.patch
  0012-Bug-487439-SIGILL-in-JDK11-JDK17.patch
  0013-Don-t-leave-fds-created-with-log-file-xml-file-or-lo.patch
  0014-Close-both-internal-pipe-fds-after-VG_-fork-in-paren.patch
  0015-Don-t-allow-programs-calling-fnctl-on-valgrind-s-own.patch
  0016-mips-skip-using-shared-syscall-numbers-for-mips64.patch
  0017-gdbserver_tests-filters-remove-python-rpm-module-loa.patch
  0018-Implement-VMOVQ-xmm1-xmm2-m64.patch
  0019-arm64-Fix-fcvtas-instruction.patch
  0020-gdbserver_tests-filters-remove-more-verbose-python-r.patch
  0021-Avoid-dev-inode-check-on-btrfs-with-sanity-level-3.patch

Resolves: #RHEL-46588
Add valgrind 3.23 stable branch fixes (rhel-10-beta)
2024-07-12 14:58:18 +02:00

75 lines
3.1 KiB
Diff

From a62058256f2c1bbc00757dfe89d505d5c6eb9906 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Thu, 4 Jul 2024 15:21:39 +0200
Subject: [PATCH 21/21] Avoid dev/inode check on btrfs with --sanity-level=3
With --sanity-level=3 or higher the aspacemgr sanity checks the
device/inode numbers from /proc/self/maps to the file stat
results. These don't match on btrfs. So detect when a file is on a
btrfs volume and ignore the check in that case.
https://bugs.kde.org/show_bug.cgi?id=317127
(cherry picked from commit 3b06d458ffc5cc8de8d701926e5d86979185fa04)
---
NEWS | 1 +
coregrind/m_aspacemgr/aspacemgr-linux.c | 13 +++++++++++++
include/vki/vki-linux.h | 6 ++++++
3 files changed, 20 insertions(+)
diff --git a/NEWS b/NEWS
index d1419b9d3c12..c5fbc8699db8 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,7 @@ The following bugs have been fixed or resolved on this branch.
202770 open fd at exit --log-socket=127.0.0.1:1500 with --track-fds=yes
311655 --log-file=FILE leads to apparent fd leak
+317127 Fedora18/x86_64 --sanity-level=3 : aspacem segment mismatch
337388 fcntl works on Valgrind's own file descriptors
391148 Unhandled AVX instruction vmovq %xmm9,%xmm1
444781 MIPS: wrong syscall numbers used
diff --git a/coregrind/m_aspacemgr/aspacemgr-linux.c b/coregrind/m_aspacemgr/aspacemgr-linux.c
index 83875e89b445..fb788e923eb4 100644
--- a/coregrind/m_aspacemgr/aspacemgr-linux.c
+++ b/coregrind/m_aspacemgr/aspacemgr-linux.c
@@ -883,6 +883,19 @@ static void sync_check_mapping_callback ( Addr addr, SizeT len, UInt prot,
/* hack apparently needed on MontaVista Linux */
if (filename && VG_(strstr)(filename, "/.lib-ro/"))
cmp_devino = False;
+
+ /* On linux systems we want to avoid dev/inode check on btrfs,
+ we can use the statfs call for that, except on nanomips
+ (which also doesn't have a sys_fstatfs syswrap).
+ See https://bugs.kde.org/show_bug.cgi?id=317127 */
+#if !defined(VGP_nanomips_linux)
+ struct vki_statfs statfs = {0};
+ SysRes res = VG_(do_syscall2)(__NR_statfs, (UWord)filename,
+ (UWord)&statfs);
+ if (!sr_isError(res) && statfs.f_type == VKI_BTRFS_SUPER_MAGIC) {
+ cmp_devino = False;
+ }
+#endif
#endif
/* If we are doing sloppy execute permission checks then we
diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h
index be3d76690cee..ccdb808af7a6 100644
--- a/include/vki/vki-linux.h
+++ b/include/vki/vki-linux.h
@@ -5455,6 +5455,12 @@ struct vki_open_how {
#define VKI_CLOSE_RANGE_UNSHARE (1U << 1)
#define VKI_CLOSE_RANGE_CLOEXEC (1U << 2)
+//----------------------------------------------------------------------
+// From linux/magic.h
+//----------------------------------------------------------------------
+
+#define VKI_BTRFS_SUPER_MAGIC 0x9123683E
+
/*--------------------------------------------------------------------*/
/*--- end ---*/
/*--------------------------------------------------------------------*/
--
2.45.2