[msan] mprotect() more memory to detect user code outside of application range.

llvm-svn: 206028
This commit is contained in:
Evgeniy Stepanov 2014-04-11 12:04:29 +00:00
parent 962b38e4f3
commit d326c81117
2 changed files with 6 additions and 5 deletions

View File

@ -299,9 +299,8 @@ void __msan_init() {
__msan_clear_on_return();
if (__msan_get_track_origins())
VPrintf(1, "msan_track_origins\n");
if (!InitShadow(/* prot1 */ false, /* prot2 */ true, /* map_shadow */ true,
__msan_get_track_origins())) {
// FIXME: prot1 = false is only required when running under DR.
if (!InitShadow(/* prot1 */ !msan_running_under_dr, /* prot2 */ true,
/* map_shadow */ true, __msan_get_track_origins())) {
Printf("FATAL: MemorySanitizer can not mmap the shadow memory.\n");
Printf("FATAL: Make sure to compile with -fPIE and to link with -pie.\n");
Printf("FATAL: Disabling ASLR is known to cause this error.\n");

View File

@ -39,7 +39,7 @@ static const uptr kMemBeg = 0x600000000000;
static const uptr kMemEnd = 0x7fffffffffff;
static const uptr kShadowBeg = MEM_TO_SHADOW(kMemBeg);
static const uptr kShadowEnd = MEM_TO_SHADOW(kMemEnd);
static const uptr kBad1Beg = 0x100000000; // 4G
static const uptr kBad1Beg = 0;
static const uptr kBad1End = kShadowBeg - 1;
static const uptr kBad2Beg = kShadowEnd + 1;
static const uptr kBad2End = kMemBeg - 1;
@ -61,7 +61,9 @@ bool InitShadow(bool prot1, bool prot2, bool map_shadow, bool init_origins) {
VPrintf(1, "Bad1 : %p %p\n", kBad1Beg, kBad1End);
if (!MemoryRangeIsAvailable(kShadowBeg,
init_origins ? kOriginsEnd : kShadowEnd)) {
init_origins ? kOriginsEnd : kShadowEnd) ||
(prot1 && !MemoryRangeIsAvailable(kBad1Beg, kBad1End)) ||
(prot2 && !MemoryRangeIsAvailable(kBad2Beg, kBad2End))) {
Printf("FATAL: Shadow memory range is not available.\n");
return false;
}