|
|
a3e2b5 |
From 3d0342f0c47c293f10d417ba429ff50436d30ddb Mon Sep 17 00:00:00 2001
|
|
|
a3e2b5 |
From: Evgeny Vereshchagin <evvers@ya.ru>
|
|
|
a3e2b5 |
Date: Tue, 3 Jul 2018 03:25:53 +0000
|
|
|
a3e2b5 |
Subject: [PATCH] tests: add a wrapper for when systemd is built with ASAN
|
|
|
a3e2b5 |
|
|
|
a3e2b5 |
(cherry picked from commit 1786fae3668fa94359ee58a8c11031dc46459255)
|
|
|
a3e2b5 |
---
|
|
|
a3e2b5 |
test/test-functions | 35 ++++++++++++++++++++++++++++++++++-
|
|
|
a3e2b5 |
1 file changed, 34 insertions(+), 1 deletion(-)
|
|
|
a3e2b5 |
|
|
|
a3e2b5 |
diff --git a/test/test-functions b/test/test-functions
|
|
|
a3e2b5 |
index 4417301be9..a6f88e4545 100644
|
|
|
a3e2b5 |
--- a/test/test-functions
|
|
|
a3e2b5 |
+++ b/test/test-functions
|
|
|
a3e2b5 |
@@ -21,7 +21,7 @@ if ! ROOTLIBDIR=$(pkg-config --variable=systemdutildir systemd); then
|
|
|
a3e2b5 |
ROOTLIBDIR=/usr/lib/systemd
|
|
|
a3e2b5 |
fi
|
|
|
a3e2b5 |
|
|
|
a3e2b5 |
-BASICTOOLS="test sh bash setsid loadkeys setfont login sulogin gzip sleep echo mount umount cryptsetup date dmsetup modprobe sed cmp tee rm true false chmod chown ln"
|
|
|
a3e2b5 |
+BASICTOOLS="test sh bash setsid loadkeys setfont login sulogin gzip sleep echo mount umount cryptsetup date dmsetup modprobe sed cmp tee rm true false chmod chown ln xargs"
|
|
|
a3e2b5 |
DEBUGTOOLS="df free ls stty cat ps ln ip route dmesg dhclient mkdir cp ping dhclient strace less grep id tty touch du sort hostname find"
|
|
|
a3e2b5 |
|
|
|
a3e2b5 |
STATEDIR="${BUILD_DIR:-.}/test/$(basename $(dirname $(realpath $0)))"
|
|
|
a3e2b5 |
@@ -317,6 +317,39 @@ EOF
|
|
|
a3e2b5 |
chmod 0755 $_valgrind_wrapper
|
|
|
a3e2b5 |
}
|
|
|
a3e2b5 |
|
|
|
a3e2b5 |
+create_asan_wrapper() {
|
|
|
a3e2b5 |
+ local _asan_wrapper=$initdir/$ROOTLIBDIR/systemd-under-asan
|
|
|
a3e2b5 |
+ ddebug "Create $_asan_wrapper"
|
|
|
a3e2b5 |
+ cat >$_asan_wrapper <
|
|
|
a3e2b5 |
+#!/bin/bash
|
|
|
a3e2b5 |
+
|
|
|
a3e2b5 |
+set -x
|
|
|
a3e2b5 |
+
|
|
|
a3e2b5 |
+DEFAULT_ASAN_OPTIONS=strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1
|
|
|
a3e2b5 |
+DEFAULT_ENVIRONMENT=ASAN_OPTIONS=\$DEFAULT_ASAN_OPTIONS
|
|
|
a3e2b5 |
+
|
|
|
a3e2b5 |
+mount -t proc proc /proc
|
|
|
a3e2b5 |
+mount -t sysfs sysfs /sys
|
|
|
a3e2b5 |
+mount -o remount,rw /
|
|
|
a3e2b5 |
+
|
|
|
a3e2b5 |
+PATH_TO_ASAN=\$(find / -name '*libasan*' | sed 1q)
|
|
|
a3e2b5 |
+if [[ "\$PATH_TO_ASAN" ]]; then
|
|
|
a3e2b5 |
+ # A lot of services (most notably dbus) won't start without preloading libasan
|
|
|
a3e2b5 |
+ # See https://github.com/systemd/systemd/issues/5004
|
|
|
a3e2b5 |
+ DEFAULT_ENVIRONMENT="\$DEFAULT_ENVIRONMENT LD_PRELOAD=\$PATH_TO_ASAN"
|
|
|
a3e2b5 |
+fi
|
|
|
a3e2b5 |
+echo DefaultEnvironment=\$DEFAULT_ENVIRONMENT >>/etc/systemd/system.conf
|
|
|
a3e2b5 |
+
|
|
|
a3e2b5 |
+# ASAN and syscall filters aren't compatible with each other.
|
|
|
a3e2b5 |
+find / -name '*.service' -type f | xargs sed -i 's/^\\(MemoryDeny\\|SystemCall\\)/#\\1/'
|
|
|
a3e2b5 |
+
|
|
|
a3e2b5 |
+export ASAN_OPTIONS=\$DEFAULT_ASAN_OPTIONS:log_path=/systemd.asan.log
|
|
|
a3e2b5 |
+exec $ROOTLIBDIR/systemd "\$@"
|
|
|
a3e2b5 |
+EOF
|
|
|
a3e2b5 |
+
|
|
|
a3e2b5 |
+ chmod 0755 $_asan_wrapper
|
|
|
a3e2b5 |
+}
|
|
|
a3e2b5 |
+
|
|
|
a3e2b5 |
create_strace_wrapper() {
|
|
|
a3e2b5 |
local _strace_wrapper=$initdir/$ROOTLIBDIR/systemd-under-strace
|
|
|
a3e2b5 |
ddebug "Create $_strace_wrapper"
|