From: Vineeth Vijayan <vvijayan@mvista.com>
To: benh@kernel.crashing.org, linuxppc-dev@lists.ozlabs.org,
linux-kernel@vger.kernel.org
Cc: Vineeth Vijayan <vvijayan@mvista.com>
Subject: [PATCH] powerpc: Fix Text randomization
Date: Fri, 10 Oct 2014 11:15:26 +0530 [thread overview]
Message-ID: <1412919926-13123-1-git-send-email-vvijayan@mvista.com> (raw)
Right now there is no way to disable TEXT randomization on a PPC32
machine. text randomization happens even in the case of "echo 0 >
/proc/sys/kernel/randomize_va_space"
This happens due to the incorrect definition of ELF_ET_DYN_BASE at
arch/powerpc/include/asm/elf.h
Signed-off-by: Vineeth Vijayan <vvijayan@mvista.com>
---
Test details:
#include <stdio.h>
int main(int argc,char *argv)
{
printf("main = %p\n",main);
return 0;
}
Compile the same as position-independent executable
Results without Patch:
p5040ds:~# gcc test.c -o test -fPIE -pie
p5040ds:~# echo 2 > /proc/sys/kernel/randomize_va_space
p5040ds:~# ./test
main = 0xb7e9681c
p5040ds:~# ./test
main = 0xb7aba81c
p5040ds:~# ./test
main = 0xb7fac81c
p5040ds:~# ./test
main = 0xb7f4c81c
p5040ds:~# echo 0 > /proc/sys/kernel/randomize_va_space
p5040ds:~# ./test
main = 0x2010281c
p5040ds:~# ./test
main = 0x2018d81c
p5040ds:~# ./test
main = 0x206a981c
p5040ds:~# ./test
main = 0x2036681c
Results with Patch:
p5040ds:~# gcc test.c -o test -fPIE -pie
p5040ds:~#
p5040ds:~# echo 2 > /proc/sys/kernel/randomize_va_space
p5040ds:~#
p5040ds:~# ./test
main = 0xb78a581c
p5040ds:~# ./test
main = 0xb792c81c
p5040ds:~# ./test
main = 0xb79de81c
p5040ds:~# ./test
main = 0xb78ae81c
p5040ds:~# echo 0 > /proc/sys/kernel/randomize_va_space
p5040ds:~#
p5040ds:~# ./test
main = 0x2000081c
p5040ds:~# ./test
main = 0x2000081c
p5040ds:~# ./test
main = 0x2000081c
p5040ds:~# ./test
main = 0x2000081c
arch/powerpc/Kconfig | 1 +
arch/powerpc/include/asm/elf.h | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 4bc7b62..f99ddae 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -88,6 +88,7 @@ config PPC
select ARCH_MIGHT_HAVE_PC_PARPORT
select ARCH_MIGHT_HAVE_PC_SERIO
select BINFMT_ELF
+ select ARCH_BINFMT_ELF_RANDOMIZE_PIE
select OF
select OF_EARLY_FLATTREE
select OF_RESERVED_MEM
diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
index 888d8f3..162813b 100644
--- a/arch/powerpc/include/asm/elf.h
+++ b/arch/powerpc/include/asm/elf.h
@@ -29,7 +29,7 @@
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 (randomize_et_dyn(0x20000000))
+#define ELF_ET_DYN_BASE (0x20000000)
#define ELF_CORE_EFLAGS (is_elf2_task() ? 2 : 0)
--
1.7.9.5
next reply other threads:[~2014-10-10 5:45 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-10 5:45 Vineeth Vijayan [this message]
2014-10-15 2:08 ` powerpc: Fix Text randomization Michael Ellerman
2014-10-15 6:38 ` Vineeth Vijayan
2014-11-14 5:31 ` Vineeth Vijayan
2014-11-14 5:33 ` Vineeth Vijayan
2014-11-14 6:20 ` Michael Ellerman
2014-11-14 8:48 ` Vineeth Vijayan
-- strict thread matches above, loose matches on Subject: below --
2014-11-14 9:12 [PATCH] [powerpc] " Vineeth Vijayan
2014-11-17 6:53 ` Michael Ellerman
2014-11-18 7:10 ` Vineeth Vijayan
2014-11-18 7:20 ` Vineeth Vijayan
2014-11-18 10:26 ` Michael Ellerman
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=1412919926-13123-1-git-send-email-vvijayan@mvista.com \
--to=vvijayan@mvista.com \
--cc=benh@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.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).