llvm-project/compiler-rt/test/scudo
Kostya Kortchinsky 3afc797e42 [scudo] Fix race condition in deallocation path when Quarantine is bypassed
Summary:
There is a race window in the deallocation path when the Quarantine is bypassed.
Initially we would just erase the header of a chunk if we were not to use the
Quarantine, as opposed to using a compare-exchange primitive, to make things
faster.

It turned out to be a poor decision, as 2 threads (or more) could simultaneously
deallocate the same pointer, and if the checks were to done before the header
got erased, this would result in the pointer being added twice (or more) to
distinct thread caches, and eventually be reused.

Winning the race is not trivial but can happen with enough control over the
allocation primitives. The repro added attempts to trigger the bug, with a
moderate success rate, but it should be enough to notice if the bug ever make
its way back into the code.

Since I am changing things in this file, there are 2 smaller changes tagging
along, marking a variable `const`, and improving the Quarantine bypass test at
runtime.

Reviewers: alekseyshl, eugenis, kcc, vitalybuka

Reviewed By: eugenis, vitalybuka

Subscribers: delcypher, #sanitizers, llvm-commits

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

llvm-svn: 339705
2018-08-14 18:34:52 +00:00
..
CMakeLists.txt [scudo] Android build support 2017-09-18 15:40:53 +00:00
aligned-new.cpp [scudo] Add verbose failures in place of CHECK(0) 2018-06-15 16:45:19 +00:00
alignment.c [scudo] Make logging more consistent 2018-03-07 16:22:16 +00:00
dealloc-race.c [scudo] Fix race condition in deallocation path when Quarantine is bypassed 2018-08-14 18:34:52 +00:00
double-free.cpp [scudo] Make some tests less Linux-y 2018-02-26 17:14:44 +00:00
fsanitize.c [scudo] Add some runtime tests for the minimal runtime 2018-06-29 14:56:25 +00:00
interface.cpp [scudo] Touch memory to count as RSS 2018-01-01 18:19:06 +00:00
lit.cfg [scudo] Add some runtime tests for the minimal runtime 2018-06-29 14:56:25 +00:00
lit.site.cfg.in [scudo] Additional modifications for Android tests support 2017-09-18 20:31:57 +00:00
malloc.cpp [scudo] Implement stricter separation of C vs C++ 2017-11-01 15:28:20 +00:00
memalign.c [scudo] Add verbose failures in place of CHECK(0) 2018-06-15 16:45:19 +00:00
mismatch.cpp [scudo] Make some tests less Linux-y 2018-02-26 17:14:44 +00:00
options.cpp [scudo] Implement stricter separation of C vs C++ 2017-11-01 15:28:20 +00:00
overflow.c [scudo] Implement stricter separation of C vs C++ 2017-11-01 15:28:20 +00:00
preinit.c [scudo] Implement stricter separation of C vs C++ 2017-11-01 15:28:20 +00:00
preload.cpp [scudo] Add some runtime tests for the minimal runtime 2018-06-29 14:56:25 +00:00
quarantine.c [scudo] Implement stricter separation of C vs C++ 2017-11-01 15:28:20 +00:00
random_shuffle.cpp [scudo] Use mkdir -p when creating directories for a test 2018-07-10 13:59:59 +00:00
realloc.cpp [scudo] Make some tests less Linux-y 2018-02-26 17:14:44 +00:00
rss.c [scudo] Soft and hard RSS limit checks 2017-11-15 16:40:27 +00:00
secondary.c [scudo] Implement stricter separation of C vs C++ 2017-11-01 15:28:20 +00:00
sized-delete.cpp [scudo] Make logging more consistent 2018-03-07 16:22:16 +00:00
sizes.cpp [scudo] Add verbose failures in place of CHECK(0) 2018-06-15 16:45:19 +00:00
stats.c [scudo] Adding an interface function to print allocator stats 2018-04-25 18:52:29 +00:00
symbols.test [scudo] Add some runtime tests for the minimal runtime 2018-06-29 14:56:25 +00:00
threads.c [scudo] Implement stricter separation of C vs C++ 2017-11-01 15:28:20 +00:00
tsd_destruction.c [scudo] Implement stricter separation of C vs C++ 2017-11-01 15:28:20 +00:00
valloc.c [scudo] Add verbose failures in place of CHECK(0) 2018-06-15 16:45:19 +00:00