[PATCH] D64457: [GWP-ASan] Attempt to fix Android/ARM platforms.

Mitch Phillips via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 9 17:19:27 PDT 2019


hctim created this revision.
hctim added reviewers: cryptoad, eugenis.
Herald added subscribers: llvm-commits, Sanitizers, jfb, kristof.beyls, javed.absar, mgorny, kubamracek, srhines.
Herald added projects: Sanitizers, LLVM.

This patch re-enabled GWP-ASan for Android and other ARM platforms. It does two
things:

1. Adds -fno-emulated-tls, as the clang driver still default compiles using emulated TLS on Android.
2. Also uses sanitizer common unwinder on Android, as glibc backtrace() isn't available.

This patch should be monitored closely when submitting. I don't have the ARM32
machines that the patches initially broke to verify that this fixes the
problem, but it's a good attempt.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64457

Files:
  compiler-rt/cmake/config-ix.cmake
  compiler-rt/lib/gwp_asan/CMakeLists.txt
  compiler-rt/lib/scudo/CMakeLists.txt


Index: compiler-rt/lib/scudo/CMakeLists.txt
===================================================================
--- compiler-rt/lib/scudo/CMakeLists.txt
+++ compiler-rt/lib/scudo/CMakeLists.txt
@@ -41,9 +41,20 @@
   # Currently, Scudo uses the GwpAsan flag parser. This backs onto the flag
   # parsing mechanism of sanitizer_common. Once Scudo has its own flag parsing,
   # and parses GwpAsan options, you can remove this dependency.
-  list(APPEND SCUDO_MINIMAL_OBJECT_LIBS RTGwpAsan RTGwpAsanOptionsParser
-                                        RTGwpAsanBacktraceLibc)
-  list(APPEND SCUDO_CFLAGS -DGWP_ASAN_HOOKS)
+  list(APPEND SCUDO_MINIMAL_OBJECT_LIBS RTGwpAsan RTGwpAsanOptionsParser)
+
+  # Install GWP-ASan stubs. Also, ensure that TLS is not emulated on this
+  # platform (Android still compiles with emulated TLS by default).
+  list(APPEND SCUDO_CFLAGS -DGWP_ASAN_HOOKS -fno-emulated-tls)
+
+  # Android does not have the libc backtrace() support (from execinfo.h). In
+  # this case, we use the sanitizer common variant.
+  if (ANDROID)
+    list(APPEND SCUDO_MINIMAL_OBJECT_LIBS RTGwpAsanBacktraceSanitizerCommon
+         RTSanitizerCommonSymbolizer)
+  else()
+    list(APPEND SCUDO_MINIMAL_OBJECT_LIBS RTGwpAsanBacktraceLibc)
+  endif()
 endif()
 
 set(SCUDO_OBJECT_LIBS ${SCUDO_MINIMAL_OBJECT_LIBS})
Index: compiler-rt/lib/gwp_asan/CMakeLists.txt
===================================================================
--- compiler-rt/lib/gwp_asan/CMakeLists.txt
+++ compiler-rt/lib/gwp_asan/CMakeLists.txt
@@ -21,7 +21,8 @@
 # Ensure that GWP-ASan meets the delegated requirements of some supporting
 # allocators. Some supporting allocators (e.g. scudo standalone) cannot use any
 # parts of the C++ standard library.
-set(GWP_ASAN_CFLAGS -fno-rtti -fno-exceptions -nostdinc++ -pthread)
+set(GWP_ASAN_CFLAGS -fno-rtti -fno-exceptions -nostdinc++ -pthread
+    -fno-emulated-tls)
 append_list_if(COMPILER_RT_HAS_FPIC_FLAG -fPIC GWP_ASAN_CFLAGS)
 append_list_if(COMPILER_RT_HAS_OMIT_FRAME_POINTER_FLAG -fno-omit-frame-pointer
                GWP_ASAN_CFLAGS)
Index: compiler-rt/cmake/config-ix.cmake
===================================================================
--- compiler-rt/cmake/config-ix.cmake
+++ compiler-rt/cmake/config-ix.cmake
@@ -247,7 +247,7 @@
   set(ALL_FUZZER_SUPPORTED_ARCH ${X86_64} ${ARM64})
 endif()
 
-set(ALL_GWP_ASAN_SUPPORTED_ARCH ${X86} ${X86_64})
+set(ALL_GWP_ASAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM64} ${ARM32})
 if(APPLE)
   set(ALL_LSAN_SUPPORTED_ARCH ${X86} ${X86_64} ${MIPS64} ${ARM64})
 else()
@@ -691,7 +691,7 @@
 # TODO(hctim): Enable this on Android again. Looks like it's causing a SIGSEGV
 # for Scudo and GWP-ASan, further testing needed.
 if (COMPILER_RT_HAS_SANITIZER_COMMON AND GWP_ASAN_SUPPORTED_ARCH AND
-    OS_NAME MATCHES "Linux")
+    OS_NAME MATCHES "Android|Linux")
   set(COMPILER_RT_HAS_GWP_ASAN TRUE)
 else()
   set(COMPILER_RT_HAS_GWP_ASAN FALSE)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64457.208848.patch
Type: text/x-patch
Size: 2928 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190710/1c1e0076/attachment.bin>


More information about the llvm-commits mailing list