This is an archive of the discontinued LLVM Phabricator instance.

[MSan] Enable for SystemZ
ClosedPublic

Authored by iii on Mar 18 2020, 6:30 AM.

Details

Summary

This patch adds runtime support, adjusts tests and enables MSan.

Like for ASan and UBSan, compile the tests with -mbackchain.

Diff Detail

Event Timeline

iii created this revision.Mar 18 2020, 6:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 18 2020, 6:30 AM
Herald added subscribers: Restricted Project, hiraditya, mgorny. · View Herald Transcript

LGTM with 2 comments.

VarArgHelper implementation looks reasonable, but I did not review it in-depth.

compiler-rt/lib/msan/msan_interceptors.cpp
978 ↗(On Diff #251060)

Please upload this as a separate change.
I think there should be () around rounded_length - 1, otherwise this will trigger UB when the mapping ends at max(uintptr_t).

compiler-rt/lib/sanitizer_common/sanitizer_linux_s390.cpp
128 ↗(On Diff #251060)

Another option is to provide internal_uname() implemented via raw system call. Just FYI.

iii marked 3 inline comments as done.Mar 19 2020, 5:15 AM
iii added inline comments.
compiler-rt/lib/msan/msan_interceptors.cpp
978 ↗(On Diff #251060)

I've uploaded this with the () fix as https://reviews.llvm.org/D76426.

compiler-rt/lib/sanitizer_common/sanitizer_linux_s390.cpp
128 ↗(On Diff #251060)

Which way is the preferred one?

I chose to use libc version, because I don't need to worry about the calling sequence.

eugenis added inline comments.Mar 19 2020, 11:12 AM
compiler-rt/lib/sanitizer_common/sanitizer_linux_s390.cpp
128 ↗(On Diff #251060)

oh, I think a better way is to use DECLARE_REAL and then call REAL(uname) if you know that this function is intercepted.

iii marked 2 inline comments as done.Mar 19 2020, 1:01 PM
iii added inline comments.
compiler-rt/lib/sanitizer_common/sanitizer_linux_s390.cpp
128 ↗(On Diff #251060)

Ah, that's another problem here: this code is common for all sanitizers, but only msan intercepts uname, so right now I don't think I can tell whether uname is intercepted.

Would it make sense to move uname interceptor to sanitizer_common_interceptors.inc, or is this an overkill?

eugenis added inline comments.Mar 19 2020, 1:17 PM
compiler-rt/lib/sanitizer_common/sanitizer_linux_s390.cpp
128 ↗(On Diff #251060)

Yes, absolutely! ASan and TSan can catch races and addressability issues on the utsname argument.

vitalybuka added inline comments.
compiler-rt/lib/sanitizer_common/sanitizer_linux_s390.cpp
128 ↗(On Diff #251060)

in a separate patch, I guess.

iii marked an inline comment as done.Mar 19 2020, 4:44 PM
iii added inline comments.
compiler-rt/lib/sanitizer_common/sanitizer_linux_s390.cpp
128 ↗(On Diff #251060)

Seems like this isn't going to work either: ubsan does not use sanitizer_common_interceptors.inc, but still links with sanitizer_linux_s390.cpp. Because of this, attempting to use REAL(uname) leads to a linker error.

eugenis added inline comments.Mar 19 2020, 7:10 PM
compiler-rt/lib/sanitizer_common/sanitizer_linux_s390.cpp
128 ↗(On Diff #251060)

Then I guess I'm fine with this.
Vitaly?

vitalybuka added inline comments.Mar 19 2020, 10:09 PM
compiler-rt/lib/sanitizer_common/sanitizer_linux_s390.cpp
128 ↗(On Diff #251060)

I am fine with this.

However I would recommend separate compiler-rt and Instrumentation changes
Both needed for s390, but they are independent

llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
4907 ↗(On Diff #251060)

I guess it's better to have some test for the new Target?

iii updated this revision to Diff 252081.Mar 23 2020, 9:40 AM

Split out mmap (already landed), uname and instrumentation
changes.

Therefore, following changes need to land first:

iii retitled this revision from [MSan] Enable MSAN for SystemZ to [MSan] Enable for SystemZ.Mar 23 2020, 9:46 AM
iii edited the summary of this revision. (Show Details)
This revision is now accepted and ready to land.Mar 23 2020, 11:41 AM
vitalybuka accepted this revision.Mar 23 2020, 1:29 PM
iii updated this revision to Diff 257286.Apr 14 2020, 4:33 AM
iii edited the summary of this revision. (Show Details)

Instead of checking only top frame, compile tests with
-mbackchain, like we already do for ASan and UBSan.

iii added a comment.Apr 15 2020, 3:18 AM

@eugenis I slightly improved the tests - could you have another look please?

iii edited the summary of this revision. (Show Details)Apr 15 2020, 5:21 AM
This revision was automatically updated to reflect the committed changes.