[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1425006434-3106-2-git-send-email-keescook@chromium.org>
Date: Thu, 26 Feb 2015 19:07:10 -0800
From: Kees Cook <keescook@...omium.org>
To: akpm@...ux-foundation.org
Cc: Kees Cook <keescook@...omium.org>,
Russell King <linux@....linux.org.uk>,
Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will.deacon@....com>,
Ralf Baechle <ralf@...ux-mips.org>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Paul Mackerras <paulus@...ba.org>,
Michael Ellerman <mpe@...erman.id.au>,
Martin Schwidefsky <schwidefsky@...ibm.com>,
Heiko Carstens <heiko.carstens@...ibm.com>,
linux390@...ibm.com, x86@...nel.org,
Alexander Viro <viro@...iv.linux.org.uk>,
Oleg Nesterov <oleg@...hat.com>,
Andy Lutomirski <luto@...capital.net>,
"David A. Long" <dave.long@...aro.org>,
Andrey Ryabinin <a.ryabinin@...sung.com>,
Arun Chandran <achandran@...sta.com>,
Yann Droneaud <ydroneaud@...eya.com>,
Min-Hua Chen <orca.chen@...il.com>,
Paul Burton <paul.burton@...tec.com>,
Alex Smith <alex@...x-smith.me.uk>,
Markos Chandras <markos.chandras@...tec.com>,
Vineeth Vijayan <vvijayan@...sta.com>,
Jeff Bailey <jeffbailey@...gle.com>,
Michael Holzheu <holzheu@...ux.vnet.ibm.com>,
Ben Hutchings <ben@...adent.org.uk>,
Behan Webster <behanw@...verseincode.com>,
Ismael Ripoll <iripoll@....es>,
Hector Marco-Gisbert <hecmargi@....es>,
Jan-Simon Möller <dl9pf@....de>,
linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-mips@...ux-mips.org, linuxppc-dev@...ts.ozlabs.org,
linux-s390@...r.kernel.org, linux-fsdevel@...r.kernel.org
Subject: [PATCH 1/5] arm: factor out mmap ASLR into mmap_rnd
Move logic for mmap ASLR into separate function.
Signed-off-by: Kees Cook <keescook@...omium.org>
---
arch/arm/mm/mmap.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
index 5e85ed371364..0f8bc158f2c6 100644
--- a/arch/arm/mm/mmap.c
+++ b/arch/arm/mm/mmap.c
@@ -169,14 +169,21 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
return addr;
}
-void arch_pick_mmap_layout(struct mm_struct *mm)
+static unsigned long mmap_rnd(void)
{
- unsigned long random_factor = 0UL;
+ unsigned long rnd = 0UL;
/* 8 bits of randomness in 20 address space bits */
if ((current->flags & PF_RANDOMIZE) &&
!(current->personality & ADDR_NO_RANDOMIZE))
- random_factor = (get_random_int() % (1 << 8)) << PAGE_SHIFT;
+ rnd = (get_random_int() % (1 << 8)) << PAGE_SHIFT;
+
+ return rnd;
+}
+
+void arch_pick_mmap_layout(struct mm_struct *mm)
+{
+ unsigned long random_factor = mmap_rnd();
if (mmap_is_legacy()) {
mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists