This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] check max address from kernel is <= mmap range size
ClosedPublic

Authored by aralisza on Apr 19 2021, 12:19 PM.

Details

Summary

If these sizes do not match, asan will not work as expected. Previously, we added compile-time checks for non-iOS platforms. We check at run time for iOS because we get the max VM size from the kernel at run time.

rdar://76477969

Diff Detail

Event Timeline

aralisza created this revision.Apr 19 2021, 12:19 PM
aralisza requested review of this revision.Apr 19 2021, 12:19 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 19 2021, 12:19 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
delcypher added inline comments.
compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
1188

Suggestion. Add a variable explicitly document our intent. There's a risk that someone might change the return value but forget to change the runtime check.

if (max_vm != 0) {
  const uptr ret_value = max_vm - 1;
  CHECK_LE(ret_value, SANITIZER_MMAP_RANGE_SIZE)
  return ret_value;
}
aralisza updated this revision to Diff 338964.Apr 20 2021, 12:46 PM

assign ret value to const

aralisza edited the summary of this revision. (Show Details)
delcypher accepted this revision.Apr 21 2021, 11:31 AM

LGTM apart from the description. The description probably should mention this is the runtime counterpart to the previous patch that added static checks. We have to do this check at runtime because we get the VM size from the kernel at runtime.

This revision is now accepted and ready to land.Apr 21 2021, 11:31 AM
aralisza edited the summary of this revision. (Show Details)Apr 21 2021, 11:57 AM
aralisza retitled this revision from [draft][compiler-rt] check max address from kernel is <= mmap range size to [compiler-rt] check max address from kernel is <= mmap range size.Apr 21 2021, 12:00 PM