All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 1/1] MIPS: Enable VDSO randomization.
@ 2014-04-19  9:33 Prem Karat
  2014-04-19 13:49 ` Sergei Shtylyov
  2014-04-19 22:56 ` David Daney
  0 siblings, 2 replies; 5+ messages in thread
From: Prem Karat @ 2014-04-19  9:33 UTC (permalink / raw)
  To: linux-mips; +Cc: ddaney.cavm

Based on commit 1091458d09e1a (mmap randomization)

For 32-bit address spaces randomize within a
16MB space, for 64-bit within a 256MB space.

Signed-off-by: Prem Karat <pkarat@mvista.com>
---
 arch/mips/kernel/vdso.c |   15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/arch/mips/kernel/vdso.c b/arch/mips/kernel/vdso.c
index 0f1af58..b49c705 100644
--- a/arch/mips/kernel/vdso.c
+++ b/arch/mips/kernel/vdso.c
@@ -16,9 +16,11 @@
 #include <linux/elf.h>
 #include <linux/vmalloc.h>
 #include <linux/unistd.h>
+#include <linux/random.h>
 
 #include <asm/vdso.h>
 #include <asm/uasm.h>
+#include <asm/processor.h>
 
 /*
  * Including <asm/unistd.h> would give use the 64-bit syscall numbers ...
@@ -67,7 +69,18 @@ subsys_initcall(init_vdso);
 
 static unsigned long vdso_addr(unsigned long start)
 {
-	return STACK_TOP;
+	unsigned long offset = 0UL;
+
+	if (current->flags & PF_RANDOMIZE) {
+		offset = get_random_int();
+		offset = offset << PAGE_SHIFT;
+		if (TASK_IS_32BIT_ADDR)
+			offset &= 0xfffffful;
+		else
+			offset &= 0xffffffful;
+	}
+
+	return (STACK_TOP + offset);
 }
 
 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-04-21 18:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-19  9:33 [RFC PATCH 1/1] MIPS: Enable VDSO randomization Prem Karat
2014-04-19 13:49 ` Sergei Shtylyov
2014-04-19 22:56 ` David Daney
2014-04-21  3:40   ` Prem Karat
2014-04-21 18:38     ` David Daney

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.