[libcxx-commits] [PATCH] D146214: [ASan][libc++] Annotating std::basic_string with all allocators

Tacet via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Mar 16 04:07:31 PDT 2023


AdvenamTacet created this revision.
AdvenamTacet added a reviewer: philnik.
Herald added a subscriber: mikhail.ramalho.
Herald added a project: All.
AdvenamTacet requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

This patch is part of our efforts to support container annotations with (almost) every allocator.
Annotating `std::basic_string` with default allocator is implemented in D132769 <https://reviews.llvm.org/D132769>.

In revision D132522 <https://reviews.llvm.org/D132522>, support for non-aligned memory buffers (sharing first/last granule with other objects) was added, therefore the check for standard allocator is not necessary.
This patch removes the check in std::basic_string annotation member function (__annotate_contiguous_container) to support different allocators and also includes changes from D145628 <https://reviews.llvm.org/D145628>, creating an easy way to turn off annotations for a specific allocator.

The motivation for a research and those changes was a bug, found by Trail of Bits, in a real code where an out-of-bounds read could happen as two strings were compared via a `std::equals` function that took `iter1_begin`, `iter1_end`, `iter2_begin` iterators (with a custom comparison function).
When object `iter1` was longer than `iter2`, read out-of-bounds on `iter2` could happen. Container sanitization would detect it.

If you have any questions, please email:

- advenam.tacet at trailofbits.com
- disconnect3d at trailofbits.com


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146214

Files:
  libcxx/include/string
  libcxx/test/libcxx/containers/strings/no_asan.pass.cpp
  libcxx/test/support/asan_testing.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146214.505764.patch
Type: text/x-patch
Size: 3993 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230316/b18f1cc7/attachment-0001.bin>


More information about the libcxx-commits mailing list