[PATCH] D36754: [scudo] Application & platform compatibility changes

Kostya Kortchinsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 15 09:55:13 PDT 2017


cryptoad created this revision.

This patch changes a few (small) things around for compatibility purposes for
the current Android & Fuchsia work:

- `realloc`'ing some memory that was not allocated with `malloc`, `calloc` or `realloc`, while UB according to http://pubs.opengroup.org/onlinepubs/009695399/functions/realloc.html is more common that one would think. We now only check this if `DeallocationTypeMismatch` mismatch is set; change the "mismatch" error messages to be more homogeneous;
- some sketchily written but widely used libraries expect a call to `realloc` to copy the usable size of the old chunk to the new one instead of the requested size. We have to begrundingly abide by this de-facto standard. This doesn't seem to impact security either way, unless someone comes up with something we didn't think about;
- the CRC32 intrinsics for 64-bit take a 64-bit first argument. This is misleading as the upper 32 bits end up being ignored. This was also raising `-Wconversion` errors. Change things to take a `u32` as first argument. This also means we were (and are) only using 32 bits of the Cookie - not a big thing, but worth mentioning.
- Includes-wise: prefer `stddef.h` to `cstddef`, move `scudo_flags.h` were it is actually needed.
- Add tests for the memalign-realloc case, and the realloc-usable-size one.


https://reviews.llvm.org/D36754

Files:
  lib/scudo/scudo_allocator.cpp
  lib/scudo/scudo_allocator.h
  lib/scudo/scudo_new_delete.cpp
  test/scudo/mismatch.cpp
  test/scudo/options.cpp
  test/scudo/realloc.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36754.111196.patch
Type: text/x-patch
Size: 10496 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170815/9400215b/attachment.bin>


More information about the llvm-commits mailing list