diff options
author | Kees Cook <keescook@chromium.org> | 2014-04-03 20:28:11 -0400 |
---|---|---|
committer | Kees Cook <keescook@chromium.org> | 2014-10-16 17:38:54 -0400 |
commit | 1e6b48116a95046ec51f3d40f83aff8b006674d7 (patch) | |
tree | 1c18e08416613ef84513cb2cd52679e7af6d4d7c /arch/arm/kernel/vmlinux.lds.S | |
parent | 23a4e4050ba9c98ab67db0980a9fb20e5096d9ea (diff) |
ARM: mm: allow non-text sections to be non-executable
Adds CONFIG_ARM_KERNMEM_PERMS to separate the kernel memory regions
into section-sized areas that can have different permisions. Performs
the NX permission changes during free_initmem, so that init memory can be
reclaimed.
This uses section size instead of PMD size to reduce memory lost to
padding on non-LPAE systems.
Based on work by Brad Spengler, Larry Bassel, and Laura Abbott.
Signed-off-by: Kees Cook <keescook@chromium.org>
Tested-by: Laura Abbott <lauraa@codeaurora.org>
Acked-by: Nicolas Pitre <nico@linaro.org>
Diffstat (limited to 'arch/arm/kernel/vmlinux.lds.S')
-rw-r--r-- | arch/arm/kernel/vmlinux.lds.S | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S index 6f57cb94367f..18fd68a295ea 100644 --- a/arch/arm/kernel/vmlinux.lds.S +++ b/arch/arm/kernel/vmlinux.lds.S | |||
@@ -8,6 +8,9 @@ | |||
8 | #include <asm/thread_info.h> | 8 | #include <asm/thread_info.h> |
9 | #include <asm/memory.h> | 9 | #include <asm/memory.h> |
10 | #include <asm/page.h> | 10 | #include <asm/page.h> |
11 | #ifdef CONFIG_ARM_KERNMEM_PERMS | ||
12 | #include <asm/pgtable.h> | ||
13 | #endif | ||
11 | 14 | ||
12 | #define PROC_INFO \ | 15 | #define PROC_INFO \ |
13 | . = ALIGN(4); \ | 16 | . = ALIGN(4); \ |
@@ -90,6 +93,11 @@ SECTIONS | |||
90 | _text = .; | 93 | _text = .; |
91 | HEAD_TEXT | 94 | HEAD_TEXT |
92 | } | 95 | } |
96 | |||
97 | #ifdef CONFIG_ARM_KERNMEM_PERMS | ||
98 | . = ALIGN(1<<SECTION_SHIFT); | ||
99 | #endif | ||
100 | |||
93 | .text : { /* Real text segment */ | 101 | .text : { /* Real text segment */ |
94 | _stext = .; /* Text and read-only data */ | 102 | _stext = .; /* Text and read-only data */ |
95 | __exception_text_start = .; | 103 | __exception_text_start = .; |
@@ -145,7 +153,11 @@ SECTIONS | |||
145 | _etext = .; /* End of text and rodata section */ | 153 | _etext = .; /* End of text and rodata section */ |
146 | 154 | ||
147 | #ifndef CONFIG_XIP_KERNEL | 155 | #ifndef CONFIG_XIP_KERNEL |
156 | # ifdef CONFIG_ARM_KERNMEM_PERMS | ||
157 | . = ALIGN(1<<SECTION_SHIFT); | ||
158 | # else | ||
148 | . = ALIGN(PAGE_SIZE); | 159 | . = ALIGN(PAGE_SIZE); |
160 | # endif | ||
149 | __init_begin = .; | 161 | __init_begin = .; |
150 | #endif | 162 | #endif |
151 | /* | 163 | /* |
@@ -220,7 +232,11 @@ SECTIONS | |||
220 | . = PAGE_OFFSET + TEXT_OFFSET; | 232 | . = PAGE_OFFSET + TEXT_OFFSET; |
221 | #else | 233 | #else |
222 | __init_end = .; | 234 | __init_end = .; |
235 | #ifdef CONFIG_ARM_KERNMEM_PERMS | ||
236 | . = ALIGN(1<<SECTION_SHIFT); | ||
237 | #else | ||
223 | . = ALIGN(THREAD_SIZE); | 238 | . = ALIGN(THREAD_SIZE); |
239 | #endif | ||
224 | __data_loc = .; | 240 | __data_loc = .; |
225 | #endif | 241 | #endif |
226 | 242 | ||