This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] Use uname syscall in GetKernelAreaSize()

Authored by iii on Mar 25 2020, 7:54 AM.



Commit 5f5fb56c68e4 ("[compiler-rt] Intercept the uname() function")
broke clang-cmake-thumbv7-full-sh build:

This also affects i386.

The reason is that intercepted uname() is called by GetKernelAreaSize()
during ASAN initialization on 32-bit platforms, but the respective
interceptor is not initialized yet at this point, leading to null
pointer dereference.

Introduce internal_uname() wrapper around uname syscall, and use it in
GetKernelAreaSize() and in FixedCVE_2016_2143().

Diff Detail

Event Timeline

iii created this revision.Mar 25 2020, 7:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 25 2020, 7:54 AM
Herald added subscribers: Restricted Project, dberris. · View Herald Transcript

I'm a bit worried about introducing dlsym on common code paths in sanitizer_common, as it would break in static binaries. HWASan, at least on Android, supports that, and now it is also available on gcc+glibc which I'm pretty sure will hit this code.

I think this has to be a system call.

iii added a comment.Mar 25 2020, 1:02 PM

Ok, I can do that.

The only thing is - do I need to support oldolduname and olduname? Or can I assume everyone uses a more or less recent kernel?

iii updated this revision to Diff 252655.Mar 25 2020, 1:23 PM

Use uname syscall. Don't try olduname and oldolduname fallbacks until we know we need them.

Also, give in and reformat the code the way clang-format wants to see it.

iii retitled this revision from [compiler-rt] Use real uname() in GetKernelAreaSize() to [compiler-rt] Use uname syscall in GetKernelAreaSize().Mar 25 2020, 1:24 PM
iii edited the summary of this revision. (Show Details)
eugenis accepted this revision.Mar 25 2020, 4:41 PM

This is fine, I don't think we need to care about olduname.

This revision is now accepted and ready to land.Mar 25 2020, 4:41 PM
This revision was automatically updated to reflect the committed changes.