[PATCH] D40504: [scudo] Workaround for uninitialized Bionic globals

Kostya Kortchinsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 27 11:33:26 PST 2017


cryptoad added inline comments.


================
Comment at: lib/scudo/scudo_utils.cpp:110
 bool hasHardwareCRC32() {
-  if (&getauxval)
+  if (&getauxval && areBionicGlobalsInitialized())
     return !!(getauxval(AT_HWCAP) & HWCAP_CRC32);
----------------
alekseyshl wrote:
> So, hasHardwareCRC32ARMPosix() works fine, even that not all globals are initialized? Maybe the proper way is to repeat the check after globals are initialized (a lot more hassle, I know)?
> 
I'll see what I can whip out regarding the 2nd part of the comment.

A few other words for the record:
hasHardwareCRC32ARMPosix will work if the application has access to /proc/self/auxv. Two reasons I see why it wouldn't: /proc is not mounted yet (which is the case for init) or the file is disallowed via selinux/seccompbpf/sandboxing in general. This doesn't involve the libc globals.
getauxval will work if the first dynamic memory allocation related call isn't prior to the initialization of the Bionic globals, as it loops through __libc_auxv which is NULL at this point.
Things work with other libcs (musl, glibc) AFAICT, and is only an issue for Bionic.


https://reviews.llvm.org/D40504





More information about the llvm-commits mailing list