This is an archive of the discontinued LLVM Phabricator instance.

[asan] Support running without /proc.
ClosedPublic

Authored by eugenis on Dec 18 2018, 6:25 PM.

Details

Summary

This patch lets ASan run when /proc is not accessible (ex. not mounted
yet). It includes a special test-only flag that emulates this condition
in an unpriviledged process.

Event Timeline

eugenis created this revision.Dec 18 2018, 6:25 PM
pcc added inline comments.Dec 18 2018, 8:29 PM
compiler-rt/lib/sanitizer_common/sanitizer_posix.h
106

The purpose of this function is a little ambiguous from the name, it sounds like it might actually try to open the file. Maybe a better name would be ShouldMockFailureToOpen?

vitalybuka added inline comments.Dec 19 2018, 12:03 AM
compiler-rt/lib/asan/asan_thread.cc
302

I dont see why const_cast is needed here

compiler-rt/lib/sanitizer_common/sanitizer_procmaps_common.cc
147

what is the purpose of cache_enabled?
It's always true
also to return false, it needs to always get to IsProcMapsAvailable()

eugenis updated this revision to Diff 178998.Dec 19 2018, 5:53 PM
eugenis marked 3 inline comments as done.

.

eugenis added inline comments.Dec 19 2018, 5:54 PM
compiler-rt/lib/asan/asan_thread.cc
302

Yeah. Removed in a separate commit.

compiler-rt/lib/sanitizer_common/sanitizer_procmaps_common.cc
147

The same as in MemoryMappingLayout constructor - some users are ok with old, cached mappings, some are not. The cache is used to support sandboxing - a situation where /proc/self/maps has been accessible before, but not right now. In that case IsAvailable(true) will say yes if there is cached data.

vitalybuka added inline comments.Dec 20 2018, 3:09 PM
compiler-rt/lib/sanitizer_common/sanitizer_procmaps_common.cc
147

So who are those users who set false?
E.g. for MemoryMappingLayout constructor I see both false and true callers.

vitalybuka accepted this revision.Dec 21 2018, 11:55 AM

LGTM

compiler-rt/lib/sanitizer_common/sanitizer_procmaps_common.cc
147

So I'd remove parameter and make it always as true.

This revision is now accepted and ready to land.Dec 21 2018, 11:55 AM
krytarowski added a subscriber: krytarowski.EditedDec 22 2018, 6:17 AM

I would note that this commit is Linux only. NetBSD already sanitizers init(8) without issues. It's also running without /proc mounted.

I would note that this commit is Linux only. NetBSD already sanitizers init(8) without issues. It's also running without /proc mounted.

Yes, because *BSD have a sane interface for enumerating virtual memory mappings.
I'll mention this in commit description.

eugenis updated this revision to Diff 179521.Dec 26 2018, 1:48 PM

updated description

eugenis updated this revision to Diff 179525.Dec 26 2018, 2:23 PM

Removed an unused parameter.

This revision was automatically updated to reflect the committed changes.
Herald added a subscriber: Restricted Project. · View Herald TranscriptDec 27 2018, 1:35 PM