[PATCH] D53789: [hwasan] optionally right-align heap allocations

Dmitry Vyukov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 29 13:39:46 PDT 2018


dvyukov added inline comments.


================
Comment at: lib/hwasan/hwasan_allocator.cc:136
 
+  if (orig_size % kShadowAlignment) {
+    if (int malloc_align_right = flags()->malloc_align_right) {
----------------
eugenis wrote:
> dvyukov wrote:
> > Shouldn't we also look at user-requested alignment here? It looks like we only satisfy natural alignment.
> Yeah, at least for calls like posix_memalign.
> 
> This mode will break some things anyway, ex.:
> struct S {
>   int count;
>   char name[0];
> };
> 
> When allocated with malloc(sizeof(S) + count) the size will not be a multiple of alignment, so "count" will be misaligned. That's why this mode can not be on by default. Let's hope it is not a common case.
> 
Why will not respecting alignment argument help? That's the alignment that we ensure in normal mode.


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D53789





More information about the llvm-commits mailing list