This is an archive of the discontinued LLVM Phabricator instance.

[sanitizer] Decorate /proc/self/maps on Android.
ClosedPublic

Authored by eugenis on Feb 4 2019, 3:55 PM.

Details

Summary

Refactor the way /proc/self/maps entries are annotated to support most
(all?) posix platforms, with a special implementation for Android.
Extend the set of decorated Mmap* calls.

Generic implementation has limits (max number of files under /dev/shm is
64K on my machine), which can be conceivably reached when sanitizing
multiple programs at once. Android implemenation is essentially free, and
enabled by default.

The test in sanitizer_common is copied to hwasan and not reused directly
because hwasan fails way too many common tests at the moment.

Event Timeline

eugenis created this revision.Feb 4 2019, 3:55 PM
vitalybuka accepted this revision.Feb 5 2019, 2:04 PM
This revision is now accepted and ready to land.Feb 5 2019, 2:04 PM
eugenis updated this revision to Diff 185413.Feb 5 2019, 2:35 PM
eugenis marked an inline comment as done.

.

eugenis added inline comments.
compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cc
353

@flowerhack FYI this is resolved by internal_open-ing /dev/shm instead of relying on shm_open.

pcc added a comment.Feb 5 2019, 2:38 PM

The GetNamedMappingFd and DecorateMapping APIs seem a little awkwards to me. Everyone is using them as GetNamedMappingFd/mmap/DecorateMapping except for one place in hwasan. Would it make more sense to have a single function that does GetNamedMappingFd/mmap/DecorateMapping and continue using PR_SET_VMA_ANON_NAME in hwasan?

In D57720#1386140, @pcc wrote:

The GetNamedMappingFd and DecorateMapping APIs seem a little awkwards to me. Everyone is using them as GetNamedMappingFd/mmap/DecorateMapping except for one place in hwasan. Would it make more sense to have a single function that does GetNamedMappingFd/mmap/DecorateMapping and continue using PR_SET_VMA_ANON_NAME in hwasan?

Yes, this is way better.

pcc accepted this revision.Feb 5 2019, 4:54 PM

LGTM

Btw, I've pushed the RSS utility here:
https://github.com/google/sanitizers/blob/master/hwaddress-sanitizer/scan.cc
It depends on this change to find the shadow region. It is hwasan-specific, but can be easily adapted to other sanitizers if needed.
It's also really ugly, but I don't want to invest time in beautifying it.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 5 2019, 5:16 PM
Herald added a subscriber: delcypher. · View Herald Transcript