From: Kees Cook <keescook@chromium.org>
To: akpm@linux-foundation.org
Cc: Kees Cook <keescook@chromium.org>, Ingo Molnar <mingo@redhat.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Hector Marco-Gisbert <hecmargi@upv.es>,
Ismael Ripoll <iripoll@upv.es>,
Russell King <linux@arm.linux.org.uk>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will.deacon@arm.com>,
Ralf Baechle <ralf@linux-mips.org>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>,
Martin Schwidefsky <schwidefsky@de.ibm.com>,
Heiko Carstens <heiko.carstens@de.ibm.com>,
linux390@de.ibm.com, x86@kernel.org,
Alexander Viro <viro@zeniv.linux.org.uk>,
Andy Lutomirski <luto@amacapital.net>,
Oleg Nesterov <oleg@redhat.com>,
"David A. Long" <dave.long@linaro.org>,
Andrey Ryabinin <a.ryabinin@samsung.com>,
Arun Chandran
Subject: [PATCH v4 04/10] mips: extract logic for mmap_rnd()
Date: Wed, 4 Mar 2015 13:10:48 -0800 [thread overview]
Message-ID: <1425503454-7531-5-git-send-email-keescook@chromium.org> (raw)
In-Reply-To: <1425503454-7531-1-git-send-email-keescook@chromium.org>
In preparation for splitting out ET_DYN ASLR, extract the mmap ASLR
selection into a separate function.
Signed-off-by: Kees Cook <keescook@chromium.org>
---
It seems the entropy gets smaller as the PAGE_SIZE increases. Is this
intentional?
---
arch/mips/mm/mmap.c | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
index f1baadd56e82..9a4f1f5c1f0e 100644
--- a/arch/mips/mm/mmap.c
+++ b/arch/mips/mm/mmap.c
@@ -142,18 +142,26 @@ unsigned long arch_get_unmapped_area_topdown(struct file *filp,
addr0, len, pgoff, flags, DOWN);
}
+static unsigned long mmap_rnd(void)
+{
+ unsigned long rnd;
+
+ rnd = (unsigned long)get_random_int();
+ rnd <<= PAGE_SHIFT;
+ if (TASK_IS_32BIT_ADDR)
+ rnd &= 0xfffffful;
+ else
+ rnd &= 0xffffffful;
+
+ return rnd;
+}
+
void arch_pick_mmap_layout(struct mm_struct *mm)
{
unsigned long random_factor = 0UL;
- if (current->flags & PF_RANDOMIZE) {
- random_factor = get_random_int();
- random_factor = random_factor << PAGE_SHIFT;
- if (TASK_IS_32BIT_ADDR)
- random_factor &= 0xfffffful;
- else
- random_factor &= 0xffffffful;
- }
+ if (current->flags & PF_RANDOMIZE)
+ random_factor = mmap_rnd();
if (mmap_is_legacy()) {
mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
--
1.9.1
next prev parent reply other threads:[~2015-03-04 21:10 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-04 21:10 [PATCH v4 0/10] split ET_DYN ASLR from mmap ASLR Kees Cook
2015-03-04 21:10 ` [PATCH v4 01/10] arm: factor out mmap ASLR into mmap_rnd Kees Cook
2015-03-04 21:10 ` [PATCH v4 02/10] x86: standardize mmap_rnd() usage Kees Cook
2015-03-04 21:10 ` [PATCH v4 03/10] arm64: " Kees Cook
2015-03-17 14:47 ` Will Deacon
2015-03-17 15:19 ` Kees Cook
2015-03-04 21:10 ` Kees Cook [this message]
2015-03-04 21:10 ` [PATCH v4 05/10] powerpc: " Kees Cook
2015-03-04 21:10 ` [PATCH v4 06/10] s390: " Kees Cook
2015-03-09 17:41 ` Martin Schwidefsky
2015-03-04 21:10 ` [PATCH v4 07/10] mm: expose arch_mmap_rnd when available Kees Cook
2015-03-04 21:10 ` [PATCH v4 08/10] s390: redefine randomize_et_dyn for ELF_ET_DYN_BASE Kees Cook
2015-03-09 17:42 ` Martin Schwidefsky
2015-03-04 21:10 ` [PATCH v4 09/10] mm: split ET_DYN ASLR from mmap ASLR Kees Cook
2015-03-04 21:10 ` [PATCH v4 10/10] mm: fold arch_randomize_brk into ARCH_HAS_ELF_RANDOMIZE Kees Cook
2015-03-04 21:54 ` [PATCH v4 0/10] split ET_DYN ASLR from mmap ASLR Ingo Molnar
2015-03-04 21:58 ` Kees Cook
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=1425503454-7531-5-git-send-email-keescook@chromium.org \
--to=keescook@chromium.org \
--cc=a.ryabinin@samsung.com \
--cc=akpm@linux-foundation.org \
--cc=benh@kernel.crashing.org \
--cc=catalin.marinas@arm.com \
--cc=dave.long@linaro.org \
--cc=hecmargi@upv.es \
--cc=heiko.carstens@de.ibm.com \
--cc=iripoll@upv.es \
--cc=linux390@de.ibm.com \
--cc=linux@arm.linux.org.uk \
--cc=luto@amacapital.net \
--cc=mingo@redhat.com \
--cc=mpe@ellerman.id.au \
--cc=oleg@redhat.com \
--cc=paulus@samba.org \
--cc=ralf@linux-mips.org \
--cc=schwidefsky@de.ibm.com \
--cc=viro@zeniv.linux.org.uk \
--cc=will.deacon@arm.com \
--cc=x86@kernel.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).