From: Yang Ming <ming.1.yang@nokia-sbell.com>
To: dev@dpdk.org
Cc: Yang Ming <ming.1.yang@nokia-sbell.com>, stable@dpdk.org
Subject: [PATCH v2] eal/linux: improve ASLR check
Date: Thu, 13 Mar 2025 14:19:03 +0800 [thread overview]
Message-ID: <20250313061904.1466-1-ming.1.yang@nokia-sbell.com> (raw)
In-Reply-To: <20250228094405.1437-1-ming.1.yang@nokia-sbell.com>
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 | 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
next prev parent reply other threads:[~2025-03-13 6:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-28 9:44 [PATCH] eal/linux: enhance ASLR verification Yang Ming
2025-03-10 21:43 ` Stephen Hemminger
2025-03-12 3:13 ` Yang Ming
2025-03-12 16:29 ` Stephen Hemminger
2025-03-13 5:52 ` [External] " Yang Ming
2025-03-12 16:22 ` Stephen Hemminger
2025-03-13 6:19 ` Yang Ming [this message]
2025-03-13 15:37 ` [PATCH v2] eal/linux: improve ASLR check Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250313061904.1466-1-ming.1.yang@nokia-sbell.com \
--to=ming.1.yang@nokia-sbell.com \
--cc=dev@dpdk.org \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).