]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Check permissions when sanity checking the segment list against
authorTom Hughes <tom@compton.nu>
Tue, 4 Oct 2005 13:02:31 +0000 (13:02 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 4 Oct 2005 13:02:31 +0000 (13:02 +0000)
the kernel's memory map.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4853

coregrind/m_aspacemgr/aspacemgr.c

index f788def234d0524ea35126c45aed58bcd86e18c5..a95d73f0b9346f9f11f01b5d21ffc9604f856f01 100644 (file)
@@ -884,6 +884,7 @@ static void sync_check_mapping_callback ( Addr addr, SizeT len, UInt prot,
    for (i = iLo; i <= iHi; i++) {
 
       Bool same, cmp_offsets, cmp_devino;
+      UInt seg_prot;
    
       /* compare the kernel's offering against ours. */
       same = nsegments[i].kind == SkAnonC
@@ -891,12 +892,18 @@ static void sync_check_mapping_callback ( Addr addr, SizeT len, UInt prot,
              || nsegments[i].kind == SkFileC
              || nsegments[i].kind == SkFileV;
 
+      seg_prot = 0;
+      if (nsegments[i].hasR) seg_prot |= VKI_PROT_READ;
+      if (nsegments[i].hasW) seg_prot |= VKI_PROT_WRITE;
+      if (nsegments[i].hasX) seg_prot |= VKI_PROT_EXEC;
+
       cmp_offsets
          = nsegments[i].kind == SkFileC || nsegments[i].kind == SkFileV;
       cmp_devino
          = nsegments[i].dev != 0 || nsegments[i].ino != 0;
 
       same = same
+             && seg_prot == prot
              && (cmp_devino
                    ? (nsegments[i].dev == dev && nsegments[i].ino == ino)
                    : True)
@@ -920,9 +927,9 @@ static void sync_check_mapping_callback ( Addr addr, SizeT len, UInt prot,
    VG_(debugLog)(0,"aspacem",
                    "sync_check_mapping_callback: segment mismatch: kernel's seg:\n");
    VG_(debugLog)(0,"aspacem", 
-                   "start=0x%llx end=0x%llx dev=%u ino=%u offset=%lld\n",
+                   "start=0x%llx end=0x%llx prot=%u dev=%u ino=%u offset=%lld\n",
                    (ULong)addr, ((ULong)addr) + ((ULong)len) - 1,
-                   dev, ino, offset );
+                   prot, dev, ino, offset );
    return;
 }