]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Disallow client mmap calls with MAP_32BIT as a flag.
authorJulian Seward <jseward@acm.org>
Mon, 14 Oct 2013 14:50:57 +0000 (14:50 +0000)
committerJulian Seward <jseward@acm.org>
Mon, 14 Oct 2013 14:50:57 +0000 (14:50 +0000)
Fixes, or at least addresses, #324181.

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

coregrind/m_syswrap/syswrap-generic.c
include/vki/vki-amd64-linux.h

index 34dad5abf9a78331621bcf3f9b372c516a56759c..0e0b3f681834fb9c66b1846c9712ddad7ef1896a 100644 (file)
@@ -1996,7 +1996,7 @@ ML_(generic_PRE_sys_mmap) ( ThreadId tid,
    MapRequest mreq;
    Bool       mreq_ok;
 
-#if defined(VGO_darwin)
+#  if defined(VGO_darwin)
    // Nb: we can't use this on Darwin, it has races:
    // * needs to RETRY if advisory succeeds but map fails  
    //   (could have been some other thread in a nonblocking call)
@@ -2004,7 +2004,7 @@ ML_(generic_PRE_sys_mmap) ( ThreadId tid,
    //   (mmap will cheerfully smash whatever's already there, which might 
    //   be a new mapping from some other thread in a nonblocking call)
    VG_(core_panic)("can't use ML_(generic_PRE_sys_mmap) on Darwin");
-#endif
+#  endif
 
    if (arg2 == 0) {
       /* SuSV3 says: If len is zero, mmap() shall fail and no mapping
@@ -2027,6 +2027,15 @@ ML_(generic_PRE_sys_mmap) ( ThreadId tid,
       return VG_(mk_SysRes_Error)( VKI_EINVAL );
    }
 
+#  if defined(VKI_MAP_32BIT)
+   /* We can't support MAP_32BIT (at least, not without significant
+      complication), and it's royally unportable, so if the client
+      asks for it, just fail it. */
+   if (arg4 & VKI_MAP_32BIT) {
+      return VG_(mk_SysRes_Error)( VKI_ENOMEM );
+   }
+#  endif
+
    /* Figure out what kind of allocation constraints there are
       (fixed/hint/any), and ask aspacem what we should do. */
    mreq.start = arg1;
index 4d97ec4cb42d3c1f52ec36c0f869a60d455b3bce..77c49c9c039da1e76d88e5d0ae18d0d2cadbd278 100644 (file)
@@ -236,6 +236,7 @@ struct vki_sigcontext {
 #define VKI_MAP_PRIVATE        0x02            /* Changes are private */
 #define VKI_MAP_FIXED  0x10            /* Interpret addr exactly */
 #define VKI_MAP_ANONYMOUS      0x20    /* don't use a file */
+#define VKI_MAP_32BIT  0x40            /* only give out 32bit addresses */
 #define VKI_MAP_NORESERVE       0x4000  /* don't check for reservations */
 
 //----------------------------------------------------------------------