From patchwork Sun Feb 22 11:50:07 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Blanchard X-Patchwork-Id: 23529 X-Patchwork-Delegate: benh@kernel.crashing.org Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 0C26FDE03B for ; Sun, 22 Feb 2009 23:05:24 +1100 (EST) X-Original-To: linuxppc-dev@ozlabs.org Delivered-To: linuxppc-dev@ozlabs.org Received: by ozlabs.org (Postfix, from userid 1010) id 5121CDDDA1; Sun, 22 Feb 2009 23:01:37 +1100 (EST) Resent-From: anton@kryten Resent-Date: Sun, 22 Feb 2009 22:58:55 +1100 Resent-Message-ID: <20090222115855.GK12006@kryten> Resent-To: linuxppc-dev@ozlabs.org Message-Id: <20090222115332.932267488@samba.org> References: <20090222114957.213647384@samba.org> User-Agent: quilt/0.46-1 Date: Sun, 22 Feb 2009 22:50:07 +1100 From: Anton Blanchard To: linuxppc-dev@ozlabs.org Subject: [patch 10/10] powerpc: Randomise PIEs Content-Disposition: inline; filename=pie_randomisation.patch X-BeenThere: linuxppc-dev@ozlabs.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org Randomise ELF_ET_DYN_BASE, which is used when loading position independent executables. Signed-off-by: Anton Blanchard Index: linux-2.6/arch/powerpc/include/asm/elf.h =================================================================== --- linux-2.6.orig/arch/powerpc/include/asm/elf.h 2009-02-22 21:18:04.000000000 +1100 +++ linux-2.6/arch/powerpc/include/asm/elf.h 2009-02-22 21:34:49.000000000 +1100 @@ -178,7 +178,8 @@ 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. */ -#define ELF_ET_DYN_BASE (0x20000000) +extern unsigned long randomize_et_dyn(unsigned long base); +#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000)) /* * Our registers are always unsigned longs, whether we're a 32 bit Index: linux-2.6/arch/powerpc/kernel/process.c =================================================================== --- linux-2.6.orig/arch/powerpc/kernel/process.c 2009-02-22 21:21:14.000000000 +1100 +++ linux-2.6/arch/powerpc/kernel/process.c 2009-02-22 21:36:02.000000000 +1100 @@ -1154,3 +1154,13 @@ return ret; } + +unsigned long randomize_et_dyn(unsigned long base) +{ + unsigned long ret = PAGE_ALIGN(base + brk_rnd()); + + if (ret < base) + return base; + + return ret; +}