|
|
594167 |
From 137a22e0192941fa275b70665af7a0d54f6ad614 Mon Sep 17 00:00:00 2001
|
|
|
594167 |
From: Frantisek Sumsal <frantisek@sumsal.cz>
|
|
|
594167 |
Date: Wed, 15 Jun 2022 12:32:51 +0200
|
|
|
594167 |
Subject: [PATCH] test: drop all LD_PRELOAD-related ASan workarounds
|
|
|
594167 |
|
|
|
594167 |
since they shouldn't be necessary anymore, as we tweak the "problematic"
|
|
|
594167 |
binaries on per-binary basis.
|
|
|
594167 |
|
|
|
594167 |
(cherry picked from commit fa65ba6baac8c9241cf30802bb5fd3698d1f3189)
|
|
|
594167 |
|
|
|
594167 |
Related: #2087652
|
|
|
594167 |
---
|
|
|
594167 |
test/test-functions | 54 +--------------------------------------------
|
|
|
594167 |
1 file changed, 1 insertion(+), 53 deletions(-)
|
|
|
594167 |
|
|
|
594167 |
diff --git a/test/test-functions b/test/test-functions
|
|
|
594167 |
index a9ff561083..f55e64493d 100644
|
|
|
594167 |
--- a/test/test-functions
|
|
|
594167 |
+++ b/test/test-functions
|
|
|
594167 |
@@ -593,10 +593,6 @@ install_verity_minimal() {
|
|
|
594167 |
# missing $LD_PRELOAD libraries.
|
|
|
594167 |
inst_libs "$ASAN_RT_PATH"
|
|
|
594167 |
inst_library "$ASAN_RT_PATH"
|
|
|
594167 |
- # Create a dummy LSan suppression file otherwise gcc's ASan
|
|
|
594167 |
- # complains as it doesn't exist in the minimal image
|
|
|
594167 |
- # (i.e. when running TEST-29 or TEST-50 under sanitizers)
|
|
|
594167 |
- touch "$initdir/systemd-lsan.supp"
|
|
|
594167 |
fi
|
|
|
594167 |
cp "$os_release" "$initdir/usr/lib/os-release"
|
|
|
594167 |
ln -s ../usr/lib/os-release "$initdir/etc/os-release"
|
|
|
594167 |
@@ -792,20 +788,6 @@ if [[ ! -e "$ASAN_RT_PATH" ]]; then
|
|
|
594167 |
exit 1
|
|
|
594167 |
fi
|
|
|
594167 |
|
|
|
594167 |
-# Suppress certain leaks reported by LSan (either in external tools or bogus
|
|
|
594167 |
-# ones)
|
|
|
594167 |
-# Docs: # https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer#suppressions
|
|
|
594167 |
-#
|
|
|
594167 |
-# - fsck is called by systemd-homed and is reporting a leak we're not interested
|
|
|
594167 |
-# in
|
|
|
594167 |
-# - libLLVM is a "side effect" caused by the previous fsck leak
|
|
|
594167 |
-cat >/systemd-lsan.supp <
|
|
|
594167 |
-leak:/bin/fsck$
|
|
|
594167 |
-leak:/sbin/fsck$
|
|
|
594167 |
-leak:/lib/libLLVM
|
|
|
594167 |
-INNER_EOF
|
|
|
594167 |
-
|
|
|
594167 |
-DEFAULT_LSAN_OPTIONS=${LSAN_OPTIONS:-}:suppressions=/systemd-lsan.supp
|
|
|
594167 |
DEFAULT_ASAN_OPTIONS=${ASAN_OPTIONS:-strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1}
|
|
|
594167 |
DEFAULT_UBSAN_OPTIONS=${UBSAN_OPTIONS:-print_stacktrace=1:print_summary=1:halt_on_error=1}
|
|
|
594167 |
DEFAULT_ENVIRONMENT="ASAN_OPTIONS=\$DEFAULT_ASAN_OPTIONS UBSAN_OPTIONS=\$DEFAULT_UBSAN_OPTIONS LSAN_OPTIONS=\$DEFAULT_LSAN_OPTIONS"
|
|
|
594167 |
@@ -818,9 +800,7 @@ mount -t proc proc /proc
|
|
|
594167 |
mount -t sysfs sysfs /sys
|
|
|
594167 |
mount -o remount,rw /
|
|
|
594167 |
|
|
|
594167 |
-# A lot of services (most notably dbus) won't start without preloading libasan
|
|
|
594167 |
-# See https://github.com/systemd/systemd/issues/5004
|
|
|
594167 |
-DEFAULT_ENVIRONMENT="\$DEFAULT_ENVIRONMENT LD_PRELOAD=$ASAN_RT_PATH ASAN_RT_PATH=$ASAN_RT_PATH"
|
|
|
594167 |
+DEFAULT_ENVIRONMENT="\$DEFAULT_ENVIRONMENT ASAN_RT_PATH=$ASAN_RT_PATH"
|
|
|
594167 |
|
|
|
594167 |
if [[ "$ASAN_COMPILER" == "clang" ]]; then
|
|
|
594167 |
# Let's add the ASan DSO's path to the dynamic linker's cache. This is pretty
|
|
|
594167 |
@@ -857,38 +837,6 @@ printf "[Unit]\nConditionVirtualization=container\n\n[Service]\nTimeoutSec=240s\
|
|
|
594167 |
mkdir -p /etc/systemd/system/systemd-journal-flush.service.d
|
|
|
594167 |
printf "[Service]\nTimeoutSec=180s\n" >/etc/systemd/system/systemd-journal-flush.service.d/timeout.conf
|
|
|
594167 |
|
|
|
594167 |
-# D-Bus has troubles during system shutdown causing it to fail. Although it's
|
|
|
594167 |
-# harmless, it causes unnecessary noise in the logs, so let's disable LSan's
|
|
|
594167 |
-# at_exit check just for the dbus.service
|
|
|
594167 |
-mkdir -p /etc/systemd/system/dbus.service.d
|
|
|
594167 |
-printf "[Service]\nEnvironment=ASAN_OPTIONS=leak_check_at_exit=false\n" >/etc/systemd/system/dbus.service.d/disable-lsan.conf
|
|
|
594167 |
-
|
|
|
594167 |
-# Some utilities run via IMPORT/RUN/PROGRAM udev directives fail because
|
|
|
594167 |
-# they're uninstrumented (like dmsetup). Let's add a simple rule which sets
|
|
|
594167 |
-# LD_PRELOAD to the ASan RT library to fix this.
|
|
|
594167 |
-mkdir -p /etc/udev/rules.d
|
|
|
594167 |
-cat >/etc/udev/rules.d/00-set-LD_PRELOAD.rules <
|
|
|
594167 |
-SUBSYSTEM=="block", ENV{LD_PRELOAD}="$ASAN_RT_PATH"
|
|
|
594167 |
-INNER_EOF
|
|
|
594167 |
-chmod 0644 /etc/udev/rules.d/00-set-LD_PRELOAD.rules
|
|
|
594167 |
-
|
|
|
594167 |
-# The 'mount' utility doesn't behave well under libasan, causing unexpected
|
|
|
594167 |
-# fails during boot and subsequent test results check:
|
|
|
594167 |
-# bash-5.0# mount -o remount,rw -v /
|
|
|
594167 |
-# mount: /dev/sda1 mounted on /.
|
|
|
594167 |
-# bash-5.0# echo \$?
|
|
|
594167 |
-# 1
|
|
|
594167 |
-# Let's workaround this by clearing the previously set LD_PRELOAD env variable,
|
|
|
594167 |
-# so the libasan library is not loaded for this particular service
|
|
|
594167 |
-unset_ld_preload() {
|
|
|
594167 |
- local _dropin_dir="/etc/systemd/system/\$1.service.d"
|
|
|
594167 |
- mkdir -p "\$_dropin_dir"
|
|
|
594167 |
- printf "[Service]\nUnsetEnvironment=LD_PRELOAD\n" >"\$_dropin_dir/unset_ld_preload.conf"
|
|
|
594167 |
-}
|
|
|
594167 |
-
|
|
|
594167 |
-unset_ld_preload systemd-remount-fs
|
|
|
594167 |
-unset_ld_preload testsuite-
|
|
|
594167 |
-
|
|
|
594167 |
export ASAN_OPTIONS=\$DEFAULT_ASAN_OPTIONS:log_path=/systemd.asan.log UBSAN_OPTIONS=\$DEFAULT_UBSAN_OPTIONS
|
|
|
594167 |
exec "$ROOTLIBDIR/systemd" "\$@"
|
|
|
594167 |
EOF
|