[PATCH] D35098: [asan] For iOS/AArch64, if the dynamic shadow doesn't fit, restrict the VM space

Kuba (Brecka) Mracek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 10 15:30:40 PDT 2017


kubamracek added inline comments.


================
Comment at: lib/asan/asan_mac.cc:70
+    // Round down to multiplies of 1 MB.
+    uptr new_max_vm = RoundDownTo(largest_gap_found << SHADOW_SCALE, 0x100000);
+    RestrictMemoryToMaxAddress(new_max_vm);
----------------
alekseyshl wrote:
> Why to 1 MB? Is it a Mac requirement?
Not really, this is purely for convenience and debugging - it's nice to see the memory map nicely aligned.  I can drop this (but we'll still need to round down to at least 8*PAGE_SIZE, maybe more).


================
Comment at: lib/sanitizer_common/sanitizer_common.h:112
+                              uptr *largest_gap_found);
+void RestrictMemoryToMaxAddress(uptr max_address);
 
----------------
alekseyshl wrote:
> Why does it have to be in sanitizer_common.h? There's sanitizer_mac.h
Right.


================
Comment at: lib/sanitizer_common/sanitizer_common_nolibc.cc:41
+}
+#endif
+
----------------
alekseyshl wrote:
> I wonder what target fails without this definition?
Actually, it's safestack.a, which uses sanitizer_common, but links in a nolibc mode.


================
Comment at: lib/sanitizer_common/sanitizer_mac.cc:843
+  uptr size_to_mmap = GetMaxVirtualAddress() + 1 - max_address;
+  MmapFixedNoAccess(max_address, size_to_mmap, "high gap");
+}
----------------
alekseyshl wrote:
> Can mmap fail here?
I'll add an assert.


https://reviews.llvm.org/D35098





More information about the llvm-commits mailing list