From 9d04d0efd5e09f745b608cc5421f5be62cb3c16b Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Thu, 21 Jun 2018 01:15:17 -0700 Subject: [PATCH] env_dpdk: pick base-virtaddr that ASAN won't override ASAN has some memory address regions that it will not allow applications to use for mappings (including mmap). So when specifying --base-virtaddr to DPDK for shared/mutli-process mappings, pick an address that ASAN will allow the application to map. Ref: https://github.com/google/sanitizers/wiki/AddressSanitizerAlgorithm We will still disable ASLR while using the test stub for now. Maybe we can eliminate this too in the future, but for now just modify the autotest_common.sh comment since we've figured out how to keep ASAN from messing with the mmap hint. Signed-off-by: Jim Harris Change-Id: Ie24fd35bd22aa3ceab6271e8936775b157e5c330 Reviewed-on: https://review.gerrithub.io/416420 Tested-by: SPDK Automated Test System Reviewed-by: Ben Walker Reviewed-by: Daniel Verkamp Reviewed-by: Dariusz Stojaczyk --- lib/env_dpdk/init.c | 9 +++++++-- test/common/autotest_common.sh | 5 ++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/env_dpdk/init.c b/lib/env_dpdk/init.c index 948d98105c..c3ceff29af 100644 --- a/lib/env_dpdk/init.c +++ b/lib/env_dpdk/init.c @@ -280,8 +280,13 @@ spdk_build_eal_cmdline(const struct spdk_env_opts *opts) return -1; } - /* set the base virtual address */ - args = spdk_push_arg(args, &argcount, _sprintf_alloc("--base-virtaddr=0x1000000000")); + /* Set the base virtual address - it must be an address that is not in the + * ASAN shadow region, otherwise ASAN-enabled builds will ignore the + * mmap hint. + * + * Ref: https://github.com/google/sanitizers/wiki/AddressSanitizerAlgorithm + */ + args = spdk_push_arg(args, &argcount, _sprintf_alloc("--base-virtaddr=0x200000000000")); if (args == NULL) { return -1; } diff --git a/test/common/autotest_common.sh b/test/common/autotest_common.sh index 252a20bf8d..d534c0cb6a 100755 --- a/test/common/autotest_common.sh +++ b/test/common/autotest_common.sh @@ -367,9 +367,8 @@ function rbd_cleanup() { function start_stub() { # Disable ASLR for multi-process testing. SPDK does support using DPDK multi-process, - # but ASAN instrumentation will result in mmap hints in our specified virt address - # region getting ignored. We will reenable it again after multi-process testing - # is complete in kill_stub() + # but ASLR can still be unreliable in some cases. + # We will reenable it again after multi-process testing is complete in kill_stub() echo 0 > /proc/sys/kernel/randomize_va_space $rootdir/test/app/stub/stub $1 & stubpid=$!