[PATCH] [msan] Fix SetShadow for mappings at the end of the application address space

Jay Foad jay.foad at gmail.com
Thu Jun 25 06:37:09 PDT 2015


Hi samsonov, eugenis, wschmidt,

On PPC64 if you disable ASLR (or run under gdb) you're likely to see
mmap returning a mapping right at the end of the application address
space region. This caused SetShadow to call MEM_TO_SHADOW() on the
last+1 address in the region, which seems wrong to me; how can
MEM_TO_SHADOW() distinguish this from the first address in the following
region?

Fixed by only calling MEM_TO_SHADOW() once, on the start address.

http://reviews.llvm.org/D10735

Files:
  lib/msan/msan_poisoning.cc

Index: lib/msan/msan_poisoning.cc
===================================================================
--- lib/msan/msan_poisoning.cc
+++ lib/msan/msan_poisoning.cc
@@ -122,7 +122,7 @@
 void SetShadow(const void *ptr, uptr size, u8 value) {
   uptr PageSize = GetPageSizeCached();
   uptr shadow_beg = MEM_TO_SHADOW(ptr);
-  uptr shadow_end = MEM_TO_SHADOW((uptr)ptr + size);
+  uptr shadow_end = shadow_beg + size;
   if (value ||
       shadow_end - shadow_beg < common_flags()->clear_shadow_mmap_threshold) {
     REAL(memset)((void *)shadow_beg, value, shadow_end - shadow_beg);

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10735.28460.patch
Type: text/x-patch
Size: 582 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150625/41eaaec8/attachment.bin>


More information about the llvm-commits mailing list