[PATCH] D31092: Bypass potential libc's sysconf wrappers for sysconf(_SC_PAGESIZE) call

Aleksey Shlyapnikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 17 11:44:33 PDT 2017


alekseyshl created this revision.
Herald added a subscriber: kubamracek.

sysconf(_SC_PAGESIZE) is called very early, during sanitizer init and
any instrumented code (a wrapper/interceptor will likely be instrumented)
calling back to sanitizer before init is done will most surely crash.


https://reviews.llvm.org/D31092

Files:
  lib/sanitizer_common/sanitizer_linux.cc


Index: lib/sanitizer_common/sanitizer_linux.cc
===================================================================
--- lib/sanitizer_common/sanitizer_linux.cc
+++ lib/sanitizer_common/sanitizer_linux.cc
@@ -805,6 +805,9 @@
   return 4096;
 #elif SANITIZER_LINUX && (defined(__x86_64__) || defined(__i386__))
   return EXEC_PAGESIZE;
+#elif SANITIZER_LINUX
+  // Bypass potential sysconf wrappers.
+  return ((long (*)(int))dlsym(RTLD_NEXT, "sysconf"))(_SC_PAGESIZE);  // NOLINT
 #else
   return sysconf(_SC_PAGESIZE);  // EXEC_PAGESIZE may not be trustworthy.
 #endif


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31092.92176.patch
Type: text/x-patch
Size: 568 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170317/679488c9/attachment.bin>


More information about the llvm-commits mailing list