This is an archive of the discontinued LLVM Phabricator instance.

[ASAN] Add mmap and munmap interceptor in ASAN
ClosedPublic

Authored by kstoimenov on Jul 6 2023, 3:00 PM.

Diff Detail

Event Timeline

kstoimenov created this revision.Jul 6 2023, 3:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2023, 3:00 PM
Herald added a subscriber: Enna1. · View Herald Transcript
kstoimenov requested review of this revision.Jul 6 2023, 3:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2023, 3:00 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
vitalybuka added inline comments.Jul 6 2023, 3:14 PM
compiler-rt/lib/asan/asan_interceptors.cpp
153

why do you drop errno = errno_EINVAL; cases?
Can we keep as close as possible to hwasan_interceptors.cpp one?

177

I guess PoisonShadow will work the same way
maybe use PoisonShadow for consistency?

compiler-rt/test/asan/TestCases/mapped_mem_interceptors.c
27

__asan_poison_memory_region() before munmap

33

__asan_poison_memory_region() before mmap(r, size,

46

No newline at end of file

kstoimenov updated this revision to Diff 537913.Jul 6 2023, 3:42 PM
kstoimenov marked 4 inline comments as done.

Addressed comments.

compiler-rt/lib/asan/asan_interceptors.cpp
153

I made this change because compiler-rt/test/asan/TestCases/Linux/cuda_test.cpp failed. HWASAN implementation was somewhat restrictive because it wouldn't allow mmapping of any memory which is not managed by the sanitizers. This implementation will only manipulate shadow memory if the region is sanitizer managed.

vitalybuka accepted this revision.Jul 6 2023, 4:27 PM
vitalybuka added inline comments.
compiler-rt/lib/asan/asan_interceptors.cpp
159–161
174–178

for consistency with errno_EINVAL in mmap

This revision is now accepted and ready to land.Jul 6 2023, 4:27 PM
kstoimenov updated this revision to Diff 538156.Jul 7 2023, 8:37 AM

Addressed comments.

kstoimenov marked 2 inline comments as done.Jul 7 2023, 8:38 AM
This revision was landed with ongoing or failed builds.Jul 7 2023, 8:49 AM
This revision was automatically updated to reflect the committed changes.