[compiler-rt] r201397 - [msan] Replicate mmap-below-shadow check in mmap64 interceptor.

Evgeniy Stepanov eugeni.stepanov at gmail.com
Fri Feb 14 01:49:29 PST 2014


Author: eugenis
Date: Fri Feb 14 03:49:29 2014
New Revision: 201397

URL: http://llvm.org/viewvc/llvm-project?rev=201397&view=rev
Log:
[msan] Replicate mmap-below-shadow check in mmap64 interceptor.

Modified:
    compiler-rt/trunk/lib/msan/lit_tests/mmap_below_shadow.cc
    compiler-rt/trunk/lib/msan/msan_interceptors.cc

Modified: compiler-rt/trunk/lib/msan/lit_tests/mmap_below_shadow.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/lit_tests/mmap_below_shadow.cc?rev=201397&r1=201396&r2=201397&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/lit_tests/mmap_below_shadow.cc (original)
+++ compiler-rt/trunk/lib/msan/lit_tests/mmap_below_shadow.cc Fri Feb 14 03:49:29 2014
@@ -5,6 +5,8 @@
 
 // RUN: %clangxx_msan -m64 -O0 -DFIXED=0 %s -o %t && %t
 // RUN: %clangxx_msan -m64 -O0 -DFIXED=1 %s -o %t && %t
+// RUN: %clangxx_msan -m64 -O0 -DFIXED=0 -D_FILE_OFFSET_BITS=64 %s -o %t && %t
+// RUN: %clangxx_msan -m64 -O0 -DFIXED=1 -D_FILE_OFFSET_BITS=64 %s -o %t && %t
 
 #include <assert.h>
 #include <errno.h>

Modified: compiler-rt/trunk/lib/msan/msan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_interceptors.cc?rev=201397&r1=201396&r2=201397&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/msan/msan_interceptors.cc Fri Feb 14 03:49:29 2014
@@ -814,6 +814,14 @@ INTERCEPTOR(void *, mmap, void *addr, SI
 INTERCEPTOR(void *, mmap64, void *addr, SIZE_T length, int prot, int flags,
             int fd, OFF64_T offset) {
   ENSURE_MSAN_INITED();
+  if (addr && !MEM_IS_APP(addr)) {
+    if (flags & map_fixed) {
+      *__errno_location() = errno_EINVAL;
+      return (void *)-1;
+    } else {
+      addr = 0;
+    }
+  }
   void *res = REAL(mmap64)(addr, length, prot, flags, fd, offset);
   if (res != (void*)-1)
     __msan_unpoison(res, RoundUpTo(length, GetPageSize()));





More information about the llvm-commits mailing list