This is an archive of the discontinued LLVM Phabricator instance.

[sanitizer] [SystemZ] Abort if the kernel might be vulnerable to CVE-2016-2143.
ClosedPublic

Authored by koriakin on Apr 8 2016, 5:00 PM.

Details

Summary

In short, CVE-2016-2143 will crash the machine if a process uses both >4TB
virtual addresses and fork(). ASan, TSan, and MSan will, by necessity, map
a sizable chunk of virtual address space, which is much larger than 4TB.
Even worse, sanitizers will always use fork() for llvm-symbolizer when a bug
is detected. Disable all three by aborting on process initialization if
the running kernel version is not known to contain a fix.

Unfortunately, there's no reliable way to detect the fix without crashing
the kernel. So, we rely on whitelisting - I've included a list of upstream
kernel versions that will work. In case someone uses a distribution kernel
or applied the fix themselves, an override switch is also included.

Diff Detail

Repository
rL LLVM

Event Timeline

koriakin retitled this revision from to [sanitizer] [SystemZ] Abort if the kernel might be vulnerable to CVE-2016-2143..
koriakin updated this object.
koriakin set the repository for this revision to rL LLVM.
koriakin added a project: Restricted Project.
koriakin added a subscriber: llvm-commits.
glider added a subscriber: glider.Apr 12 2016, 7:09 AM

Note that 32-bit ASan process doesn't map >4Tb memory.

Note that 32-bit ASan process doesn't map >4Tb memory.

Yes, this is why the ifdefs are all for s390x, not for s390.

glider accepted this revision.Apr 12 2016, 10:16 AM
glider added a reviewer: glider.

The code looks good.
We may want to introduce some InitializeCommon() in sanitizer_common() to avoid putting common code in every tool, but maybe this can be done next time such a need arises.

This revision is now accepted and ready to land.Apr 12 2016, 10:16 AM

The code looks good.
We may want to introduce some InitializeCommon() in sanitizer_common() to avoid putting common code in every tool, but maybe this can be done next time such a need arises.

The thing is, we don't want this check for every sanitizer - only for sanitizers that reserve a good fraction of the address space (so UBSan and safestack are fine, LSan might be too - I haven't looked at it yet). Is there such a distinction somewhere already?

Nope, there isn't, and adding it will be an overkill indeed.

This revision was automatically updated to reflect the committed changes.
kcc added a subscriber: kcc.Apr 15 2016, 9:42 AM

So many ifdefs are bad, please don't do this. (this applies to this patch, and others)
Instead, please have a s390-specific (or SystemZ-specific) file that will define some functions (and also define those functions for everyone else as empty)
and then call those functions.