diff options
author | David Daney <ddaney.cavm@gmail.com> | 2012-01-10 18:10:21 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-10 19:30:51 -0500 |
commit | e39f560239984c3098237ad94c9449b1494163f8 (patch) | |
tree | c86d9f84a3cb706813919ec7472fb75207bc9c8c | |
parent | 5742332dea5560d6c449b007d9539dbdc8ee531b (diff) |
fs: binfmt_elf: create Kconfig variable for PIE randomization
Randomization of PIE load address is hard coded in binfmt_elf.c for X86
and ARM. Create a new Kconfig variable
(CONFIG_ARCH_BINFMT_ELF_RANDOMIZE_PIE) for this and use it instead. Thus
architecture specific policy is pushed out of the generic binfmt_elf.c and
into the architecture Kconfig files.
X86 and ARM Kconfigs are modified to select the new variable so there is
no change in behavior. A follow on patch will select it for MIPS too.
Signed-off-by: David Daney <david.daney@cavium.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Acked-by: H. Peter Anvin <hpa@zytor.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | arch/arm/Kconfig | 1 | ||||
-rw-r--r-- | arch/x86/Kconfig | 1 | ||||
-rw-r--r-- | fs/Kconfig.binfmt | 3 | ||||
-rw-r--r-- | fs/binfmt_elf.c | 2 |
4 files changed, 6 insertions, 1 deletions
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 9d66dfc33a5a..98a6459cd398 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig | |||
@@ -16,6 +16,7 @@ config ARM | |||
16 | select HAVE_FTRACE_MCOUNT_RECORD if (!XIP_KERNEL) | 16 | select HAVE_FTRACE_MCOUNT_RECORD if (!XIP_KERNEL) |
17 | select HAVE_DYNAMIC_FTRACE if (!XIP_KERNEL) | 17 | select HAVE_DYNAMIC_FTRACE if (!XIP_KERNEL) |
18 | select HAVE_FUNCTION_GRAPH_TRACER if (!THUMB2_KERNEL) | 18 | select HAVE_FUNCTION_GRAPH_TRACER if (!THUMB2_KERNEL) |
19 | select ARCH_BINFMT_ELF_RANDOMIZE_PIE | ||
19 | select HAVE_GENERIC_DMA_COHERENT | 20 | select HAVE_GENERIC_DMA_COHERENT |
20 | select HAVE_KERNEL_GZIP | 21 | select HAVE_KERNEL_GZIP |
21 | select HAVE_KERNEL_LZO | 22 | select HAVE_KERNEL_LZO |
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 1d2a69dd36d8..d6ddc0bfe36a 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig | |||
@@ -62,6 +62,7 @@ config X86 | |||
62 | select ANON_INODES | 62 | select ANON_INODES |
63 | select HAVE_ARCH_KMEMCHECK | 63 | select HAVE_ARCH_KMEMCHECK |
64 | select HAVE_USER_RETURN_NOTIFIER | 64 | select HAVE_USER_RETURN_NOTIFIER |
65 | select ARCH_BINFMT_ELF_RANDOMIZE_PIE | ||
65 | select HAVE_ARCH_JUMP_LABEL | 66 | select HAVE_ARCH_JUMP_LABEL |
66 | select HAVE_TEXT_POKE_SMP | 67 | select HAVE_TEXT_POKE_SMP |
67 | select HAVE_GENERIC_HARDIRQS | 68 | select HAVE_GENERIC_HARDIRQS |
diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt index 79e2ca7973b7..e95d1b64082c 100644 --- a/fs/Kconfig.binfmt +++ b/fs/Kconfig.binfmt | |||
@@ -27,6 +27,9 @@ config COMPAT_BINFMT_ELF | |||
27 | bool | 27 | bool |
28 | depends on COMPAT && BINFMT_ELF | 28 | depends on COMPAT && BINFMT_ELF |
29 | 29 | ||
30 | config ARCH_BINFMT_ELF_RANDOMIZE_PIE | ||
31 | bool | ||
32 | |||
30 | config BINFMT_ELF_FDPIC | 33 | config BINFMT_ELF_FDPIC |
31 | bool "Kernel support for FDPIC ELF binaries" | 34 | bool "Kernel support for FDPIC ELF binaries" |
32 | default y | 35 | default y |
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 21ac5ee4b43f..bcb884e2d613 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c | |||
@@ -794,7 +794,7 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs) | |||
794 | * default mmap base, as well as whatever program they | 794 | * default mmap base, as well as whatever program they |
795 | * might try to exec. This is because the brk will | 795 | * might try to exec. This is because the brk will |
796 | * follow the loader, and is not movable. */ | 796 | * follow the loader, and is not movable. */ |
797 | #if defined(CONFIG_X86) || defined(CONFIG_ARM) | 797 | #ifdef CONFIG_ARCH_BINFMT_ELF_RANDOMIZE_PIE |
798 | /* Memory randomization might have been switched off | 798 | /* Memory randomization might have been switched off |
799 | * in runtime via sysctl. | 799 | * in runtime via sysctl. |
800 | * If that is the case, retain the original non-zero | 800 | * If that is the case, retain the original non-zero |