linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: akpm@linux-foundation.org
Cc: linux-mips@linux-mips.org, "Arun Chandran" <achandran@mvista.com>,
	"Catalin Marinas" <catalin.marinas@arm.com>,
	"Heiko Carstens" <heiko.carstens@de.ibm.com>,
	linux-kernel@vger.kernel.org,
	"Min-Hua Chen" <orca.chen@gmail.com>,
	"Paul Mackerras" <paulus@samba.org>,
	"Ismael Ripoll" <iripoll@upv.es>,
	"Yann Droneaud" <ydroneaud@opteya.com>,
	linux-s390@vger.kernel.org,
	"Russell King" <linux@arm.linux.org.uk>,
	"Andrey Ryabinin" <a.ryabinin@samsung.com>,
	"Behan Webster" <behanw@converseincode.com>,
	x86@kernel.org, "Hector Marco-Gisbert" <hecmargi@upv.es>,
	"David A. Long" <dave.long@linaro.org>,
	"Ben Hutchings" <ben@decadent.org.uk>,
	"Kees Cook" <keescook@chromium.org>,
	"Will Deacon" <will.deacon@arm.com>,
	linux-fsdevel@vger.kernel.org,
	"Alex Smith" <alex@alex-smith.me.uk>,
	"Michael Holzheu" <holzheu@linux.vnet.ibm.com>,
	linux-arm-kernel@lists.infradead.org,
	"Jeff Bailey" <jeffbailey@google.com>,
	"Paul Burton" <paul.burton@imgtec.com>,
	"Oleg Nesterov" <oleg@redhat.com>,
	"Ralf Baechle" <ralf@linux-mips.org>,
	"Andy Lutomirski" <luto@amacapital.net>,
	"Vineeth Vijayan" <vvijayan@mvista.com>,
	"Markos Chandras" <markos.chandras@imgtec.com>,
	"Jan-Simon Möller" <dl9pf@gmx.de>,
	"Martin Schwidefsky" <schwidefsky@de.ibm.com>,
	linux390@de.ibm.com, linuxppc-dev@lists.ozlabs.org,
	"Alexander Viro" <viro@zeniv.linux.org.uk>
Subject: [PATCH 3/5] mm: move randomize_et_dyn into ELF_ET_DYN_BASE
Date: Thu, 26 Feb 2015 19:07:12 -0800	[thread overview]
Message-ID: <1425006434-3106-4-git-send-email-keescook@chromium.org> (raw)
In-Reply-To: <1425006434-3106-1-git-send-email-keescook@chromium.org>

This moves s390's randomize_et_dyn base into ELF_ET_DYN_BASE, and removes
an unused arm64 extern.

Signed-off-by: Kees Cook <keescook@chromium.org>
---
 arch/arm64/include/asm/elf.h |  1 -
 arch/s390/include/asm/elf.h  |  9 +++++----
 arch/s390/mm/mmap.c          | 11 -----------
 3 files changed, 5 insertions(+), 16 deletions(-)

diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h
index 1f65be393139..f724db00b235 100644
--- a/arch/arm64/include/asm/elf.h
+++ b/arch/arm64/include/asm/elf.h
@@ -125,7 +125,6 @@ typedef struct user_fpsimd_state elf_fpregset_t;
  * the loader.  We need to make sure that it is out of the way of the program
  * that it will "exec", and that there is sufficient room for the brk.
  */
-extern unsigned long randomize_et_dyn(unsigned long base);
 #define ELF_ET_DYN_BASE	(2 * TASK_SIZE_64 / 3)
 
 /*
diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
index c9df40b5c0ac..9ed68e7ee856 100644
--- a/arch/s390/include/asm/elf.h
+++ b/arch/s390/include/asm/elf.h
@@ -161,10 +161,11 @@ extern unsigned int vdso_enabled;
 /* This is the location that an ET_DYN program is loaded if exec'ed.  Typical
    use of this is to invoke "./ld.so someprog" to test out a new version of
    the loader.  We need to make sure that it is out of the way of the program
-   that it will "exec", and that there is sufficient room for the brk.  */
-
-extern unsigned long randomize_et_dyn(void);
-#define ELF_ET_DYN_BASE		randomize_et_dyn()
+   that it will "exec", and that there is sufficient room for the brk. 64-bit
+   tasks are aligned to 4GB. */
+#define ELF_ET_DYN_BASE (arch_mmap_rnd() + (is_32bit_task() ? \
+				(STACK_TOP / 3 * 2) : \
+				(STACK_TOP / 3 * 2) & ~((1UL << 32) - 1)))
 
 /* This yields a mask that user programs can use to figure out what
    instruction set this CPU supports. */
diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
index 77759e35671b..ec4c20448aef 100644
--- a/arch/s390/mm/mmap.c
+++ b/arch/s390/mm/mmap.c
@@ -179,17 +179,6 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
 	return addr;
 }
 
-unsigned long randomize_et_dyn(void)
-{
-	unsigned long base;
-
-	base = STACK_TOP / 3 * 2;
-	if (!is_32bit_task())
-		/* Align to 4GB */
-		base &= ~((1UL << 32) - 1);
-	return base + arch_mmap_rnd();
-}
-
 #ifndef CONFIG_64BIT
 
 /*
-- 
1.9.1

  parent reply	other threads:[~2015-02-27  3:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-27  3:07 [PATCH 0/5] split ET_DYN ASLR from mmap ASLR Kees Cook
2015-02-27  3:07 ` [PATCH 1/5] arm: factor out mmap ASLR into mmap_rnd Kees Cook
2015-02-27  3:07 ` [PATCH 2/5] mm: expose arch_mmap_rnd when available Kees Cook
2015-02-27  3:07 ` Kees Cook [this message]
2015-02-27  3:07 ` [PATCH 4/5] mm: split ET_DYN ASLR from mmap ASLR Kees Cook
2015-02-27  3:07 ` [PATCH 5/5] mm: fold arch_randomize_brk into ARCH_HAS_ELF_RANDOMIZE Kees Cook
2015-02-27  6:19 ` [PATCH 0/5] split ET_DYN ASLR from mmap ASLR Ingo Molnar
2015-03-02 21:26 ` Andrew Morton
2015-03-02 22:22   ` Kees Cook
2015-03-03  0:19 [PATCH v2 " Kees Cook
2015-03-03  0:19 ` [PATCH 3/5] mm: move randomize_et_dyn into ELF_ET_DYN_BASE 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=1425006434-3106-4-git-send-email-keescook@chromium.org \
    --to=keescook@chromium.org \
    --cc=a.ryabinin@samsung.com \
    --cc=achandran@mvista.com \
    --cc=akpm@linux-foundation.org \
    --cc=alex@alex-smith.me.uk \
    --cc=behanw@converseincode.com \
    --cc=ben@decadent.org.uk \
    --cc=catalin.marinas@arm.com \
    --cc=dave.long@linaro.org \
    --cc=dl9pf@gmx.de \
    --cc=hecmargi@upv.es \
    --cc=heiko.carstens@de.ibm.com \
    --cc=holzheu@linux.vnet.ibm.com \
    --cc=iripoll@upv.es \
    --cc=jeffbailey@google.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux390@de.ibm.com \
    --cc=linux@arm.linux.org.uk \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=luto@amacapital.net \
    --cc=markos.chandras@imgtec.com \
    --cc=oleg@redhat.com \
    --cc=orca.chen@gmail.com \
    --cc=paul.burton@imgtec.com \
    --cc=paulus@samba.org \
    --cc=ralf@linux-mips.org \
    --cc=schwidefsky@de.ibm.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=vvijayan@mvista.com \
    --cc=will.deacon@arm.com \
    --cc=x86@kernel.org \
    --cc=ydroneaud@opteya.com \
    /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).