From 4f83a5dd7dfa6219cc29449600031dd336d6ed8d Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Wed, 27 Nov 2024 14:58:16 +0100 Subject: [PATCH] Drone: Report errors when failing to change KASLR --- .drone/drone.sh | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/.drone/drone.sh b/.drone/drone.sh index 361f2a01..b234dfa5 100755 --- a/.drone/drone.sh +++ b/.drone/drone.sh @@ -22,13 +22,20 @@ set +x echo '==================================> INSTALL' if [[ $(uname) == "Linux" ]]; then - # Temporarily allow failures changing those values as the job might not need them - set +e - # Avoid ASAN "DEADLYSIGNAL" errors - echo 0 | sudo tee /proc/sys/kernel/randomize_va_space - # Avoid TSAN "FATAL: ThreadSanitizer: unexpected memory mapping" errors - sudo sysctl vm.mmap_rnd_bits=28 - set -e + error=0 + if ! { echo 0 | sudo tee /proc/sys/kernel/randomize_va_space > /dev/null; } && [[ -n ${B2_ASAN:-} ]]; then + echo -e "\n\nWARNING: Failed to disable KASLR. ASAN might fail with 'DEADLYSIGNAL'." + error=1 + fi + # sysctl just ignores some failures and does't return an error, only output + if { ! out=$(sudo sysctl vm.mmap_rnd_bits=28) || [[ "$out" == *"ignoring:"* ]]; } && [[ -n ${B2_TSAN:-} ]]; then + echo -e "\n\nWARNING: Failed to change KASLR. TSAN might fail with 'FATAL: ThreadSanitizer: unexpected memory mapping'." + error=1 + fi + if ((error == 1)); then + [[ "${DRONE_EXTRA_PRIVILEGED:-0}" == "True" ]] || echo 'Try passing `privileged=True` to the job in .drone.star' + echo -e "\n" + fi fi scripts=(