DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] eal/linux: enhance ASLR verification
@ 2025-02-28  9:44 Yang Ming
  0 siblings, 0 replies; only message in thread
From: Yang Ming @ 2025-02-28  9:44 UTC (permalink / raw)
  To: Anatoly Burakov; +Cc: dev, Yang Ming, stable

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: stable@dpdk.org

Signed-off-by: Yang Ming <ming.1.yang@nokia-sbell.com>
---
 lib/eal/linux/eal_memory.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/eal/linux/eal_memory.c b/lib/eal/linux/eal_memory.c
index 9dda60c0e1..ab1fd83cf2 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>
@@ -26,7 +27,6 @@
 #include <numa.h>
 #include <numaif.h>
 #endif
-
 #include <rte_errno.h>
 #include <rte_log.h>
 #include <rte_memory.h>
@@ -200,6 +200,14 @@ static int
 aslr_enabled(void)
 {
 	char c;
+
+	/*
+	 * check whether the current process is executed with command line
+	 * "setarch ... --addr-no-randomize ...".
+	 */
+	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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-02-28  9:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-28  9:44 [PATCH] eal/linux: enhance ASLR verification Yang Ming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).