]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Avoid dev/inode check on btrfs with --sanity-level=3 VALGRIND_3_23_BRANCH
authorMark Wielaard <mark@klomp.org>
Thu, 4 Jul 2024 13:21:39 +0000 (15:21 +0200)
committerMark Wielaard <mark@klomp.org>
Fri, 5 Jul 2024 10:08:08 +0000 (12:08 +0200)
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
coregrind/m_aspacemgr/aspacemgr-linux.c
include/vki/vki-linux.h

diff --git a/NEWS b/NEWS
index d1419b9d3c1288f33525ac93b5a052481bb52685..c5fbc8699db840d861e723bd3e962a2465ed860a 100644 (file)
--- 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
index 83875e89b445189caa2b379fdb67db027ad4c970..fb788e923eb418732ed4a239994b63f1539b2f59 100644 (file)
@@ -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
index be3d76690ceecee92c96bc9db9bafd7387cc98cf..ccdb808af7a6790948aabfdba7f2a66948e22ba3 100644 (file)
@@ -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                                                          ---*/
 /*--------------------------------------------------------------------*/