[compiler-rt] r240690 - [msan] Fix SetShadow for mappings at the end of the application address space

Jay Foad jay.foad at gmail.com
Thu Jun 25 13:47:59 PDT 2015


Author: foad
Date: Thu Jun 25 15:47:59 2015
New Revision: 240690

URL: http://llvm.org/viewvc/llvm-project?rev=240690&view=rev
Log:
[msan] Fix SetShadow for mappings at the end of the application address space

Summary:
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.

Reviewers: samsonov, wschmidt, eugenis

Reviewed By: eugenis

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D10735

Modified:
    compiler-rt/trunk/lib/msan/msan_poisoning.cc

Modified: compiler-rt/trunk/lib/msan/msan_poisoning.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_poisoning.cc?rev=240690&r1=240689&r2=240690&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan_poisoning.cc (original)
+++ compiler-rt/trunk/lib/msan/msan_poisoning.cc Thu Jun 25 15:47:59 2015
@@ -122,7 +122,7 @@ void CopyMemory(void *dst, const void *s
 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);





More information about the llvm-commits mailing list