[PATCH] D38574: [Sanitizers] ASan: detect new/delete calls with mismatched alignment.

Aleksey Shlyapnikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 4 21:41:19 PDT 2017


alekseyshl created this revision.
Herald added a subscriber: kubamracek.

ASan allocator stores the requested alignment for new and new[] calls
and on delete and delete[] verifies that alignments do match.

The representable alignments are: default alignment, 8, 16, 32, 64, 128,
256 and 512 bytes. Alignments > 512 are stored as 512, hence two
different alignments > 512 will pass the check (possibly masking the bug),
but limited memory requirements deemed to be a resonable tradeoff for
relaxed conditions.

The feature is controlled by new_delete_type_mismatch flag, the same one
protecting new/delete matching size check.

Issue: https://github.com/google/sanitizers/issues/799


https://reviews.llvm.org/D38574

Files:
  lib/asan/asan_allocator.cc
  lib/asan/asan_allocator.h
  lib/asan/asan_descriptions.cc
  lib/asan/asan_descriptions.h
  lib/asan/asan_errors.cc
  lib/asan/asan_errors.h
  lib/asan/asan_new_delete.cc
  lib/asan/asan_report.cc
  lib/asan/asan_report.h
  test/asan/TestCases/Linux/aligned_delete_test.cc

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38574.117773.patch
Type: text/x-patch
Size: 24788 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171005/0499e81c/attachment.bin>


More information about the llvm-commits mailing list