From 4b1dbc948b9d63fcc8e917f17ecc3ff1b3866f86 Mon Sep 17 00:00:00 2001 From: Michal Berger Date: Thu, 23 Jan 2020 00:22:05 +0100 Subject: [PATCH] test/common: Don't take randomize_va_space default setting for granted Currently, kill_stub() doesn't gracefully handle this particular sysctl since it overwrites it with assumed default that doesn't necessarily have to be a part of kernel's config on a given system. Don't presume what the setting should be, instead, read and save the current value and try to restore it whenever kill_stub() is called. Change-Id: I1f1ee85c29d5e2ec2f442a54f700e3bc45ee2437 Signed-off-by: Michal Berger Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/482652 Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- test/common/autotest_common.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/common/autotest_common.sh b/test/common/autotest_common.sh index 8fef13765..2105cc4cc 100644 --- a/test/common/autotest_common.sh +++ b/test/common/autotest_common.sh @@ -578,7 +578,9 @@ function rbd_cleanup() { function start_stub() { # Disable ASLR for multi-process testing. SPDK does support using DPDK multi-process, # but ASLR can still be unreliable in some cases. - # We will reenable it again after multi-process testing is complete in kill_stub() + # We will reenable it again after multi-process testing is complete in kill_stub(). + # Save current setting so it can be restored upon calling kill_stub(). + _randomize_va_space=$( /proc/sys/kernel/randomize_va_space $rootdir/test/app/stub/stub $1 & stubpid=$! @@ -596,7 +598,7 @@ function kill_stub() { # Re-enable ASLR now that we are done with multi-process testing # Note: "1" enables ASLR w/o randomizing data segments, "2" adds data segment # randomizing and is the default on all recent Linux kernels - echo 2 > /proc/sys/kernel/randomize_va_space + echo "${_randomize_va_space:-2}" > /proc/sys/kernel/randomize_va_space } function run_test() {