Skip to contentSkip to conversation

ARM: the ADDR_NO_RANDOMIZE personality flag should be honored with mmap()

PATCH New Nicolas Pitre 2 participants 3 messages Apr 8, 2011 – Apr 14, 2011 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ARM: the ADDR_NO_RANDOMIZE personality flag should be honored with mmap()

---
 arch/arm/mm/mmap.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
arch/arm/mm/mmap.c +3 -1
index afe209e..74be05f 100644
@@ -7,6 +7,7 @@
 #include <linux/shm.h>
 #include <linux/sched.h>
 #include <linux/io.h>
+#include <linux/personality.h>
 #include <linux/random.h>
 #include <asm/cputype.h>
 #include <asm/system.h>
@@ -82,7 +83,8 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
 	        mm->cached_hole_size = 0;
 	}
 	/* 8 bits of randomness in 20 address space bits */
-	if (current->flags & PF_RANDOMIZE)
+	if ((current->flags & PF_RANDOMIZE) &&
+	    !(current->personality & ADDR_NO_RANDOMIZE))
 		addr += (get_random_int() % (1 << 8)) << PAGE_SHIFT;
 
 full_search:
Signature · 1 line
1.7.4
#1 lore raw

PATCH 1/2 ARM: the ADDR_NO_RANDOMIZE personality flag should be honored with mmap()

Quoted 2 lines · Nicolas Pitre

---

Is this a stable candidate?

Quoted 25 lines
 arch/arm/mm/mmap.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
arch/arm/mm/mmap.c +3 -1
index afe209e..74be05f 100644
@@ -7,6 +7,7 @@
 #include <linux/shm.h>
 #include <linux/sched.h>
 #include <linux/io.h>
+#include <linux/personality.h>
 #include <linux/random.h>
 #include <asm/cputype.h>
 #include <asm/system.h>
@@ -82,7 +83,8 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
 	        mm->cached_hole_size = 0;
 	}
 	/* 8 bits of randomness in 20 address space bits */
-	if (current->flags & PF_RANDOMIZE)
+	if ((current->flags & PF_RANDOMIZE) &&
+	    !(current->personality & ADDR_NO_RANDOMIZE))
 		addr += (get_random_int() % (1 << 8)) << PAGE_SHIFT;
 
 full_search:
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#2 lore raw

PATCH 1/2 ARM: the ADDR_NO_RANDOMIZE personality flag should be honored with mmap()

Quoted 5 lines · Stephen Boyd
Quoted 2 lines · Nicolas Pitre

---

Is this a stable candidate?

Maybe, but OTOH this is not critical. You also need to have CONFIG_COMPAT_BRK=n before this makes any difference, and that option is enabled by default.

Nicolas