This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC]Disable randomized address space on Linux ppc64le
ClosedPublic

Authored by lei on Oct 4 2018, 12:01 PM.

Details

Summary

Recent versions of Ubuntu (17.04 and 18.04) on PowerPC have introduced changes to Address Space Layout Randomization (ASLR) that is causing 500+ sanitizer failures. This patch disables ASLR when running the sanitizers on PowerPC 64bit LE.

We are continuing to investigate a long-term solution that will allow the sanitizers to run with ASLR enabled. However, in the meantime this will allow the sanitizers to function correctly on these systems.

Diff Detail

Repository
rL LLVM

Event Timeline

lei created this revision.Oct 4 2018, 12:01 PM
Herald added subscribers: Restricted Project, llvm-commits, jsji and 2 others. · View Herald TranscriptOct 4 2018, 12:01 PM
seurer added a comment.Oct 8 2018, 1:59 PM

The similar change for aarch64 was done in

compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc

which seems a more "natural" location for this. Will that location not work for powerpc64?

Also, the wording of the warning is terrible (same as in the aarch64 one).

The similar change for aarch64 was done in

compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc

which seems a more "natural" location for this. Will that location not work for powerpc64?

I thought this needed to be done for more than just tsan on PPC. Lei can correct me if I'm wrong here.

Also, the wording of the warning is terrible (same as in the aarch64 one).

Feel free to suggest a different wording.

compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
1998 ↗(On Diff #168343)

The comment does not match the macro. I expect that SANITIZER_PPC64V2 means:
"Sanitizer turned on, platform is PPC, ELFv2 ABI". The ELFv2 ABI does not necessarily suggest Linux on little endian. For example, FreeBSD big endian uses the same ABI.

lei added a comment.Oct 9 2018, 7:22 AM

For PPC this needs to be done for both tsan and msan.

compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
1998 ↗(On Diff #168343)

FreeBSD defines SANITIZER_FREEBSD. This is only for PPCLE.

seurer added a comment.EditedOct 9 2018, 7:43 AM

TSAN/MSAN: Ahh, got it.

As for the wording, how about something like this.

WARNING: This program is being run with address space layout randomization (ASLR) enabled which prevents the thread and memory sanitizers from working on powerpc64le. ASLR will be disabled and the program re-executed.

As for the wording, how about something like this.

WARNING: This program is being run with address space layout randomization (ASLR) enabled which prevents the thread and memory sanitizers from working on powerpc64le. ASLR will be disabled and the program re-executed.

I like it! And it somehow comes up highlighted in Phabricator :)

Do you have more information about the change in Ubuntu that caused this to stop working?

It is not specific to Ubuntu but is changes in how wide a range of addresses that the kernel chooses when ASLR is enabled. After some updates in the 4.x kernels (sorry, I am not sure which ones) the range is hundreds of times bigger which makes choosing the constants that the sanitizers use impossible.

As examples on a 4.4 kernel memory was very roughly in this range (sampled from many test runs):
0x0000000100000984 to 0x000000013FFF0984 which is a range of about 3FFF0000

While on a 4.15 kernel it was this:
0x0000000100980984 to 0x00001000F7E90984 which is a range of FFFF7510000

(both systems were Ubuntu)

lei updated this revision to Diff 168850.Oct 9 2018, 11:59 AM

Warning message updated.

lei added a comment.Oct 15 2018, 6:50 AM

Any other concerns about committing this patch?

FWIW it looks good to me

marxin added a subscriber: marxin.Oct 25 2018, 12:41 AM
lei added a reviewer: nemanjai.Nov 2 2018, 7:50 AM
nemanjai accepted this revision.Nov 2 2018, 7:57 AM

Since this fixes the sanitizers on PPC for the newer kernels and the fix seems perfectly reasonable and there are no concerns brought up by anyone, let's go ahead with this fix.

This revision is now accepted and ready to land.Nov 2 2018, 7:57 AM
This revision was automatically updated to reflect the committed changes.