This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] assert max virtual address is <= mmap range size
ClosedPublic

Authored by aralisza on Apr 9 2021, 5:48 PM.

Details

Summary

If these sizes do not match, asan will not work as expected.

If possible, assert at compile time that the vm size is less than or equal to mmap range.
If a compile time assert is not possible, check at run time (for iOS)

rdar://76477969

Diff Detail

Event Timeline

aralisza created this revision.Apr 9 2021, 5:48 PM
aralisza requested review of this revision.Apr 9 2021, 5:48 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 9 2021, 5:48 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
aralisza retitled this revision from [draft][compiler-rt]assert max virtual address is less than mmap range size to [compiler-rt] assert max virtual address is <= mmap range size.Apr 15 2021, 4:43 PM
aralisza edited the summary of this revision. (Show Details)
aralisza added reviewers: delcypher, yln.
aralisza added a reviewer: kubamracek.
aralisza updated this revision to Diff 337944.Apr 15 2021, 4:46 PM

remove trailing whitesepace

yln added inline comments.Apr 15 2021, 6:14 PM
compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
1187–1189

Needs braces or CHECK_LE moved before if.

delcypher requested changes to this revision.Apr 16 2021, 12:48 PM
delcypher added inline comments.
compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
1188–1189

There's an inconsistency here. The static checks are checking with -1 already subtracted. The runtime check here is testing without -1 subtracted.

I think we should be checking whatever we are going to return at runtime.

1193

Why do we we need the static keyword here?

This revision now requires changes to proceed.Apr 16 2021, 12:48 PM
yln added inline comments.Apr 16 2021, 1:47 PM
compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
1188–1189

I think we should be checking whatever we are going to return at runtime.

+1

While I usually really like the idea of compile-time checks (always better to catch mistakes earlier rather than later), I don't think it's worth the complexity/visual noise in this specific case.

Having one check for the final runtime value seems the clearest expression of intent here.

aralisza updated this revision to Diff 338596.Apr 19 2021, 12:18 PM

remove runtime check for ios

aralisza added inline comments.Apr 19 2021, 12:28 PM
compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
1188–1189

moved the runtime check to separate diff per offline discussion. should I still remove the static checks? I think they still add value, especially if we're not going to add the runtime checks until a later time

aralisza updated this revision to Diff 338609.Apr 19 2021, 12:47 PM

remove static keyword for max vm constants

LGTM apart from the static keyword which "I think" shouldn't be necessary here.

compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
1188–1189

I'm fine with the static checks here. I think failing earlier at compile time when the constants are wrong is a good thing :)

delcypher accepted this revision.Apr 19 2021, 12:56 PM
This revision is now accepted and ready to land.Apr 19 2021, 12:56 PM
yln accepted this revision.Apr 19 2021, 1:35 PM
This revision was landed with ongoing or failed builds.Apr 19 2021, 2:01 PM
This revision was automatically updated to reflect the committed changes.