Skip to content

Commit b2e7e5c

Browse files
committed
Drone: Report errors when failing to change KASLR
1 parent d6ccde9 commit b2e7e5c

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

.drone/drone.sh

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,20 @@ set +x
2222
echo '==================================> INSTALL'
2323

2424
if [[ $(uname) == "Linux" ]]; then
25-
# Temporarily allow failures changing those values as the job might not need them
26-
set +e
27-
# Avoid ASAN "DEADLYSIGNAL" errors
28-
echo 0 | sudo tee /proc/sys/kernel/randomize_va_space
29-
# Avoid TSAN "FATAL: ThreadSanitizer: unexpected memory mapping" errors
30-
sudo sysctl vm.mmap_rnd_bits=28
31-
set -e
25+
error=0
26+
if ! { echo 0 | sudo tee /proc/sys/kernel/randomize_va_space > /dev/null; } && [[ -n ${B2_ASAN:-} ]]; then
27+
echo -e "\n\nWARNING: Failed to disable KASLR. ASAN might fail with 'DEADLYSIGNAL'."
28+
error=1
29+
fi
30+
# sysctl just ignores some failures and does't return an error, only output
31+
if { ! out=$(sudo sysctl vm.mmap_rnd_bits=28 2>&1) || [[ "$out" == *"ignoring:"* ]]; } && [[ -n ${B2_TSAN:-} ]]; then
32+
echo -e "\n\nWARNING: Failed to change KASLR. TSAN might fail with 'FATAL: ThreadSanitizer: unexpected memory mapping'."
33+
error=1
34+
fi
35+
if ((error == 1)); then
36+
[[ "${DRONE_EXTRA_PRIVILEGED:-0}" == "True" ]] || echo 'Try passing `privileged=True` to the job in .drone.star'
37+
echo -e "\n"
38+
fi
3239
fi
3340

3441
scripts=(

0 commit comments

Comments
 (0)