[PATCH] D79656: [hwasan] Fix allocator alignment.

Kostya Kortchinsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 8 18:49:17 PDT 2020


cryptoad accepted this revision.
cryptoad added inline comments.
This revision is now accepted and ready to land.


================
Comment at: compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h:78
     } else {
-      NonConstSpaceBeg = address_range.Init(TotalSpaceSize,
-                                            PrimaryAllocatorName);
+      NonConstSpaceBeg = address_range.InitAligned(
+          TotalSpaceSize, SizeClassMap::kMaxSize, PrimaryAllocatorName);
----------------
Since we had the discussion, I understand the need to be aligned, but maybe a comment to clarify why for later readers?


================
Comment at: compiler-rt/lib/sanitizer_common/sanitizer_common.cpp:328
+                                       const char *name) {
+  if (align <= GetPageSizeCached())
+    return Init(size, name);
----------------
Maybe a safe guard check that align is a power of 2?
With SizeClassMap::kMaxSize it's the case, but if it's used somewhere else, it might slip through.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79656/new/

https://reviews.llvm.org/D79656





More information about the llvm-commits mailing list