[compiler-rt] r218124 - [asan] asan_device_setup improvements.

Evgeniy Stepanov eugeni.stepanov at gmail.com
Fri Sep 19 08:04:44 PDT 2014


Author: eugenis
Date: Fri Sep 19 10:04:44 2014
New Revision: 218124

URL: http://llvm.org/viewvc/llvm-project?rev=218124&view=rev
Log:
[asan] asan_device_setup improvements.

* Allow user SEGV handler if Android-L-like setup is detected.
  Necessary for correctness.
* Change file context labels on the wrapper script to appease SELinux.

Modified:
    compiler-rt/trunk/lib/asan/scripts/asan_device_setup

Modified: compiler-rt/trunk/lib/asan/scripts/asan_device_setup
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/scripts/asan_device_setup?rev=218124&r1=218123&r2=218124&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/scripts/asan_device_setup (original)
+++ compiler-rt/trunk/lib/asan/scripts/asan_device_setup Fri Sep 19 10:04:44 2014
@@ -160,13 +160,19 @@ cp "$ASAN_RT_PATH/$ASAN_RT" "$TMPDIR/"
 # FIXME: alloc_dealloc_mismatch=0 prevents a failure in libdvm startup,
 # which may or may not be a real bug (probably not).
 ASAN_OPTIONS=start_deactivated=1,alloc_dealloc_mismatch=0
+
+# On Android-L not allowing user segv handler breaks some applications.
+if $ADB shell 'echo $LD_PRELOAD' | grep libsigchain.so >&/dev/null; then
+    ASAN_OPTIONS="$ASAN_OPTIONS,allow_user_segv_handler=1"
+fi
+
 if [[ x$extra_options != x ]] ; then
     ASAN_OPTIONS="$ASAN_OPTIONS,$extra_options"
 fi
 
 # Zygote wrapper.
 cat <<EOF >"$TMPDIR/app_process.wrap"
-#!/system/bin/sh
+#!/system/bin/sh-from-zygote
 ASAN_OPTIONS=$ASAN_OPTIONS \\
 LD_PRELOAD=\$LD_PRELOAD:libclang_rt.asan-arm-android.so \\
 exec /system/bin/app_process32 \$@
@@ -201,6 +207,13 @@ if ! ( cd "$TMPDIRBASE" && diff -qr old/
         /system/bin/app_process.wrap \
         /system/bin/asanwrapper
 
+    # Make SELinux happy by keeping app_process wrapper and the shell
+    # it runs on in zygote domain.
+    $ADB shell cp /system/bin/sh /system/bin/sh-from-zygote
+    $ADB shell chcon u:object_r:zygote_exec:s0 \
+        /system/bin/sh-from-zygote \
+        /system/bin/app_process.wrap
+
     echo '>> Restarting shell (asynchronous)'
     $ADB shell stop
     $ADB shell start





More information about the llvm-commits mailing list