From: Julian Seward Date: Mon, 14 Oct 2013 14:50:57 +0000 (+0000) Subject: Disallow client mmap calls with MAP_32BIT as a flag. X-Git-Tag: svn/VALGRIND_3_9_0~47 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4fc45578f6826163315c205fa15db7d6d85ac211;p=thirdparty%2Fvalgrind.git Disallow client mmap calls with MAP_32BIT as a flag. Fixes, or at least addresses, #324181. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13644 --- diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c index 34dad5abf9..0e0b3f6818 100644 --- a/coregrind/m_syswrap/syswrap-generic.c +++ b/coregrind/m_syswrap/syswrap-generic.c @@ -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; diff --git a/include/vki/vki-amd64-linux.h b/include/vki/vki-amd64-linux.h index 4d97ec4cb4..77c49c9c03 100644 --- a/include/vki/vki-amd64-linux.h +++ b/include/vki/vki-amd64-linux.h @@ -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 */ //----------------------------------------------------------------------