aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/include/asm/pgtable.h
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2008-09-07 12:16:54 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-10-01 11:41:10 -0400
commit8ec53663d2698076468b3e1edc4e1b418bd54de3 (patch)
treed98f0ac21ec96be15aab1b05d3d6e2f60a657815 /arch/arm/include/asm/pgtable.h
parent5ec9407dd1196daaf12b427b351e2cd62d2a16a7 (diff)
[ARM] Improve non-executable support
Add support for detecting non-executable stack binaries, and adjust permissions to prevent execution from data and stack areas. Also, ensure that READ_IMPLIES_EXEC is enabled for older CPUs where that is true, and for any executable-stack binary. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/include/asm/pgtable.h')
-rw-r--r--arch/arm/include/asm/pgtable.h47
1 files changed, 27 insertions, 20 deletions
diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
index e5054b026c24..b02be6c55aef 100644
--- a/arch/arm/include/asm/pgtable.h
+++ b/arch/arm/include/asm/pgtable.h
@@ -197,22 +197,29 @@ extern void __pgd_error(const char *file, int line, unsigned long val);
197 * shared mapping bits. 197 * shared mapping bits.
198 */ 198 */
199#define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG 199#define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
200#define _L_PTE_READ L_PTE_USER | L_PTE_EXEC
201 200
202extern pgprot_t pgprot_user; 201extern pgprot_t pgprot_user;
203extern pgprot_t pgprot_kernel; 202extern pgprot_t pgprot_kernel;
204 203
205#define PAGE_NONE pgprot_user 204#define _MOD_PROT(p, b) __pgprot(pgprot_val(p) | (b))
206#define PAGE_COPY __pgprot(pgprot_val(pgprot_user) | _L_PTE_READ) 205
207#define PAGE_SHARED __pgprot(pgprot_val(pgprot_user) | _L_PTE_READ | \ 206#define PAGE_NONE pgprot_user
208 L_PTE_WRITE) 207#define PAGE_SHARED _MOD_PROT(pgprot_user, L_PTE_USER | L_PTE_WRITE)
209#define PAGE_READONLY __pgprot(pgprot_val(pgprot_user) | _L_PTE_READ) 208#define PAGE_SHARED_EXEC _MOD_PROT(pgprot_user, L_PTE_USER | L_PTE_WRITE | L_PTE_EXEC)
210#define PAGE_KERNEL pgprot_kernel 209#define PAGE_COPY _MOD_PROT(pgprot_user, L_PTE_USER)
211 210#define PAGE_COPY_EXEC _MOD_PROT(pgprot_user, L_PTE_USER | L_PTE_EXEC)
212#define __PAGE_NONE __pgprot(_L_PTE_DEFAULT) 211#define PAGE_READONLY _MOD_PROT(pgprot_user, L_PTE_USER)
213#define __PAGE_COPY __pgprot(_L_PTE_DEFAULT | _L_PTE_READ) 212#define PAGE_READONLY_EXEC _MOD_PROT(pgprot_user, L_PTE_USER | L_PTE_EXEC)
214#define __PAGE_SHARED __pgprot(_L_PTE_DEFAULT | _L_PTE_READ | L_PTE_WRITE) 213#define PAGE_KERNEL pgprot_kernel
215#define __PAGE_READONLY __pgprot(_L_PTE_DEFAULT | _L_PTE_READ) 214#define PAGE_KERNEL_EXEC _MOD_PROT(pgprot_kernel, L_PTE_EXEC)
215
216#define __PAGE_NONE __pgprot(_L_PTE_DEFAULT)
217#define __PAGE_SHARED __pgprot(_L_PTE_DEFAULT | L_PTE_USER | L_PTE_WRITE)
218#define __PAGE_SHARED_EXEC __pgprot(_L_PTE_DEFAULT | L_PTE_USER | L_PTE_WRITE | L_PTE_EXEC)
219#define __PAGE_COPY __pgprot(_L_PTE_DEFAULT | L_PTE_USER)
220#define __PAGE_COPY_EXEC __pgprot(_L_PTE_DEFAULT | L_PTE_USER | L_PTE_EXEC)
221#define __PAGE_READONLY __pgprot(_L_PTE_DEFAULT | L_PTE_USER)
222#define __PAGE_READONLY_EXEC __pgprot(_L_PTE_DEFAULT | L_PTE_USER | L_PTE_EXEC)
216 223
217#endif /* __ASSEMBLY__ */ 224#endif /* __ASSEMBLY__ */
218 225
@@ -228,19 +235,19 @@ extern pgprot_t pgprot_kernel;
228#define __P001 __PAGE_READONLY 235#define __P001 __PAGE_READONLY
229#define __P010 __PAGE_COPY 236#define __P010 __PAGE_COPY
230#define __P011 __PAGE_COPY 237#define __P011 __PAGE_COPY
231#define __P100 __PAGE_READONLY 238#define __P100 __PAGE_READONLY_EXEC
232#define __P101 __PAGE_READONLY 239#define __P101 __PAGE_READONLY_EXEC
233#define __P110 __PAGE_COPY 240#define __P110 __PAGE_COPY_EXEC
234#define __P111 __PAGE_COPY 241#define __P111 __PAGE_COPY_EXEC
235 242
236#define __S000 __PAGE_NONE 243#define __S000 __PAGE_NONE
237#define __S001 __PAGE_READONLY 244#define __S001 __PAGE_READONLY
238#define __S010 __PAGE_SHARED 245#define __S010 __PAGE_SHARED
239#define __S011 __PAGE_SHARED 246#define __S011 __PAGE_SHARED
240#define __S100 __PAGE_READONLY 247#define __S100 __PAGE_READONLY_EXEC
241#define __S101 __PAGE_READONLY 248#define __S101 __PAGE_READONLY_EXEC
242#define __S110 __PAGE_SHARED 249#define __S110 __PAGE_SHARED_EXEC
243#define __S111 __PAGE_SHARED 250#define __S111 __PAGE_SHARED_EXEC
244 251
245#ifndef __ASSEMBLY__ 252#ifndef __ASSEMBLY__
246/* 253/*