This is an archive of the discontinued LLVM Phabricator instance.

[sanitizer] Split MmapFixedNoReserve into a version that disallows overwriting existing memory and one that allows it
AcceptedPublic

Authored by kubamracek on Aug 2 2017, 1:32 PM.

Details

Summary

Multiple times during work on sanitizers, I've hit a situation where the shadow memory initialization (done via mmap) would overwrite some existing memory. This patch changes MmapFixedNoReserve to add a safety check to fail when something already occupies the region we're trying to map into, and introduces MmapFixedNoReserveAllowOverwrite which explicitly allows overwriting memory. Same for MmapFixedNoAccess and MmapFixedNoAccessAllowOverwrite.

The patch implements this for Darwin only currently, but if there's a some Linux and Windows API to do the same, I'll be happy to add them.

Diff Detail

Event Timeline

kubamracek created this revision.Aug 2 2017, 1:32 PM
vitalybuka edited edge metadata.Aug 16 2017, 2:44 PM

LGTM

lib/sanitizer_common/sanitizer_common.h
98

misaligned

vitalybuka accepted this revision.Aug 21 2017, 3:20 PM
This revision is now accepted and ready to land.Aug 21 2017, 3:20 PM