[asan] Implement "scribble" flags, which overwrite free'd memory with 0x55
authorKuba Mracek <mracek@apple.com>
Thu, 30 Mar 2017 15:44:57 +0000 (15:44 +0000)
committerKuba Mracek <mracek@apple.com>
Thu, 30 Mar 2017 15:44:57 +0000 (15:44 +0000)
commitfe7e91b0033fb44b09764d13cc7346ffe6dec15e
tree2a0e231852b435f55f1dfecf1cf3c1fbcd18c4a2
parent281979b12d4756bbba4ea48c052ad8a18af6469f
[asan] Implement "scribble" flags, which overwrite free'd memory with 0x55

This patch implements "Malloc Scribble" in ASan via "max_free_fill_size" and "free_fill_byte" flags, which can be used to overwrite free()'d memory. We also match the behavior of MallocScribble and MallocPreScribble env vars on macOS (see https://developer.apple.com/library/content/documentation/Performance/Conceptual/ManagingMemory/Articles/MallocDebug.html), which is a helpful tool to detect use-after-free bugs that happen in non-instrumented code.

Differential Revision: https://reviews.llvm.org/D30101

llvm-svn: 299085
compiler-rt/lib/asan/asan_allocator.cc
compiler-rt/lib/asan/asan_flags.cc
compiler-rt/lib/asan/asan_flags.inc
compiler-rt/test/asan/TestCases/Darwin/scribble.cc [new file with mode: 0644]
compiler-rt/test/asan/TestCases/scribble.cc [new file with mode: 0644]