This change ensures that the current process is checked for being run with 'setarch' before verifying the value of '/proc/sys/kernel/randomize_va_space'. The '-R' or '--addr-no-randomize' parameter of the 'setarch' command is used to disable the randomization of the virtual address space.
Fixes: af75078fece3 ("first public release") Cc: sta...@dpdk.org Signed-off-by: Yang Ming <ming.1.y...@nokia-sbell.com> --- lib/eal/linux/eal_memory.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/eal/linux/eal_memory.c b/lib/eal/linux/eal_memory.c index 9dda60c0e1..5ef1575b66 100644 --- a/lib/eal/linux/eal_memory.c +++ b/lib/eal/linux/eal_memory.c @@ -15,6 +15,7 @@ #include <sys/stat.h> #include <sys/file.h> #include <sys/resource.h> +#include <sys/personality.h> #include <unistd.h> #include <limits.h> #include <signal.h> @@ -200,6 +201,17 @@ static int aslr_enabled(void) { char c; + + /* + * Check whether the current process is executed with the command line + * "setarch ... --addr-no-randomize ..." or "setarch ... -R ..." + * This complements the sysfs check to ensure comprehensive ASLR status detection. + * This check is necessary to support the functionality of the "setarch" command, + * which can disable ASLR by setting the ADDR_NO_RANDOMIZE personality flag. + */ + if ((personality(0xffffffff) & ADDR_NO_RANDOMIZE) == ADDR_NO_RANDOMIZE) + return 0; + int retval, fd = open(RANDOMIZE_VA_SPACE_FILE, O_RDONLY); if (fd < 0) return -errno; -- 2.34.1