This is an archive of the discontinued LLVM Phabricator instance.

[scudo][standalone] Fix a race in the secondary release
ClosedPublic

Authored by cryptoad on Feb 5 2020, 9:59 AM.

Details

Summary

I tried to move the madvise calls outside of one of the secondary
mutexes, but this backfired. There is situation when a low release
interval is set combined with secondary pressure that leads to a race:
a thread can get a block from the cache, while another thread is
madvise'ing that block, resulting in a null header.

I changed the secondary race test so that this situation would be
triggered, and moved the release into the cache mutex scope.

Diff Detail

Event Timeline

cryptoad created this revision.Feb 5 2020, 9:59 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptFeb 5 2020, 9:59 AM
Herald added subscribers: Restricted Project, jfb. · View Herald Transcript
cryptoad marked an inline comment as done.Feb 5 2020, 10:00 AM
cryptoad added inline comments.
compiler-rt/lib/scudo/standalone/secondary.h
100

And I forgot to say that the Data field was not copied.
In practice this didn't matter since only Fuchsia is using it and it doesn't support caching.

Unit tests: pass. 62503 tests passed, 0 failed and 844 were skipped.

clang-tidy: pass.

clang-format: fail. Please format your changes with clang-format by running git-clang-format HEAD^ or applying this patch.

Build artifacts: clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project.

pcc accepted this revision.Feb 5 2020, 10:28 AM

LGTM

This revision is now accepted and ready to land.Feb 5 2020, 10:28 AM
cryptoad updated this revision to Diff 242691.Feb 5 2020, 10:34 AM

Retrying clang-format.

Unit tests: pass. 62503 tests passed, 0 failed and 844 were skipped.

clang-tidy: pass.

clang-format: fail. Please format your changes with clang-format by running git-clang-format HEAD^ or applying this patch.

Build artifacts: clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project.

This revision was automatically updated to reflect the committed changes.