summaryrefslogtreecommitdiff
path: root/lib/msan/msan_poisoning.cc
diff options
context:
space:
mode:
authorJay Foad <jay.foad@gmail.com>2015-06-25 20:47:59 +0000
committerJay Foad <jay.foad@gmail.com>2015-06-25 20:47:59 +0000
commit166c3254b23b865f2fb22a5fa118977b4138ec87 (patch)
tree63fdd2e42274561be8237449045849dc9928ed61 /lib/msan/msan_poisoning.cc
parent366e7b9f26da422874aad1727a87f7356465b09d (diff)
[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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@240690 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/msan/msan_poisoning.cc')
-rw-r--r--lib/msan/msan_poisoning.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/msan/msan_poisoning.cc b/lib/msan/msan_poisoning.cc
index 96411fdbc..92134f6a1 100644
--- a/lib/msan/msan_poisoning.cc
+++ b/lib/msan/msan_poisoning.cc
@@ -122,7 +122,7 @@ void CopyMemory(void *dst, const void *src, uptr size, StackTrace *stack) {
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);