aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHelge Deller <deller@parisc-linux.org>2006-01-13 15:21:06 -0500
committerKyle McMartin <kyle@duet.int.mcmartin.ca>2006-01-22 20:26:54 -0500
commit1bcdd8548286743e1d6b3d53c96a90c6da975620 (patch)
treeb244aa416992bbd06c4153ec2c97022629826ef2
parenta2bb214dcd1db862fdb6421e21f1cff0c3535162 (diff)
[PARISC] Add CONFIG_DEBUG_RODATA to protect read-only data
Add the parisc version of the "mark rodata section read only" patches. Based on code from and Signed-off-by Arjan van de Ven <arjan@infradead.org>, Ingo Molnar <mingo@elte.hu>, Andi Kleen <ak@muc.de>, Andrew Morton <akpm@osdl.org>, Linus Torvalds <torvalds@osdl.org>. Signed-off-by: Helge Deller <deller@parisc-linux.org> Signed-off-by: Kyle McMartin <kyle@parisc-linux.org>
-rw-r--r--arch/parisc/Kconfig.debug10
-rw-r--r--arch/parisc/hpux/entry_hpux.S3
-rw-r--r--arch/parisc/kernel/syscall.S2
-rw-r--r--arch/parisc/mm/init.c15
-rw-r--r--include/asm-parisc/cacheflush.h6
-rw-r--r--include/asm-parisc/pgtable.h2
6 files changed, 34 insertions, 4 deletions
diff --git a/arch/parisc/Kconfig.debug b/arch/parisc/Kconfig.debug
index 8caaed187a1f..9166bd117267 100644
--- a/arch/parisc/Kconfig.debug
+++ b/arch/parisc/Kconfig.debug
@@ -11,4 +11,14 @@ config DEBUG_RWLOCK
11 too many attempts. If you suspect a rwlock problem or a kernel 11 too many attempts. If you suspect a rwlock problem or a kernel
12 hacker asks for this option then say Y. Otherwise say N. 12 hacker asks for this option then say Y. Otherwise say N.
13 13
14config DEBUG_RODATA
15 bool "Write protect kernel read-only data structures"
16 depends on DEBUG_KERNEL
17 help
18 Mark the kernel read-only data as write-protected in the pagetables,
19 in order to catch accidental (and incorrect) writes to such const
20 data. This option may have a slight performance impact because a
21 portion of the kernel code won't be covered by a TLB anymore.
22 If in doubt, say "N".
23
14endmenu 24endmenu
diff --git a/arch/parisc/hpux/entry_hpux.S b/arch/parisc/hpux/entry_hpux.S
index fa9bf38787e7..31c8cccfba31 100644
--- a/arch/parisc/hpux/entry_hpux.S
+++ b/arch/parisc/hpux/entry_hpux.S
@@ -22,10 +22,9 @@
22#include <linux/linkage.h> 22#include <linux/linkage.h>
23#include <asm/unistd.h> 23#include <asm/unistd.h>
24 24
25 .text
26
27#define ENTRY_NAME(_name_) .word _name_ 25#define ENTRY_NAME(_name_) .word _name_
28 26
27 .section .rodata,"a"
29 .align 4 28 .align 4
30 .export hpux_call_table 29 .export hpux_call_table
31 .import hpux_unimplemented_wrapper 30 .import hpux_unimplemented_wrapper
diff --git a/arch/parisc/kernel/syscall.S b/arch/parisc/kernel/syscall.S
index d66163492890..af88afef41bd 100644
--- a/arch/parisc/kernel/syscall.S
+++ b/arch/parisc/kernel/syscall.S
@@ -650,6 +650,8 @@ end_linux_gateway_page:
650#define LWS_ENTRY(_name_) .word (lws_##_name_ - linux_gateway_page) 650#define LWS_ENTRY(_name_) .word (lws_##_name_ - linux_gateway_page)
651#endif 651#endif
652 652
653 .section .rodata,"a"
654
653 .align 4096 655 .align 4096
654 /* Light-weight-syscall table */ 656 /* Light-weight-syscall table */
655 /* Start of lws table. */ 657 /* Start of lws table. */
diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c
index 9999eb045238..6f36d0b17d9e 100644
--- a/arch/parisc/mm/init.c
+++ b/arch/parisc/mm/init.c
@@ -417,6 +417,19 @@ void free_initmem(void)
417#endif 417#endif
418} 418}
419 419
420
421#ifdef CONFIG_DEBUG_RODATA
422void mark_rodata_ro(void)
423{
424 extern char __start_rodata, __end_rodata;
425 /* rodata memory was already mapped with KERNEL_RO access rights by
426 pagetable_init() and map_pages(). No need to do additional stuff here */
427 printk (KERN_INFO "Write protecting the kernel read-only data: %luk\n",
428 (unsigned long)(&__end_rodata - &__start_rodata) >> 10);
429}
430#endif
431
432
420/* 433/*
421 * Just an arbitrary offset to serve as a "hole" between mapping areas 434 * Just an arbitrary offset to serve as a "hole" between mapping areas
422 * (between top of physical memory and a potential pcxl dma mapping 435 * (between top of physical memory and a potential pcxl dma mapping
@@ -685,7 +698,7 @@ static void __init pagetable_init(void)
685 698
686#ifdef CONFIG_BLK_DEV_INITRD 699#ifdef CONFIG_BLK_DEV_INITRD
687 if (initrd_end && initrd_end > mem_limit) { 700 if (initrd_end && initrd_end > mem_limit) {
688 printk("initrd: mapping %08lx-%08lx\n", initrd_start, initrd_end); 701 printk(KERN_INFO "initrd: mapping %08lx-%08lx\n", initrd_start, initrd_end);
689 map_pages(initrd_start, __pa(initrd_start), 702 map_pages(initrd_start, __pa(initrd_start),
690 initrd_end - initrd_start, PAGE_KERNEL); 703 initrd_end - initrd_start, PAGE_KERNEL);
691 } 704 }
diff --git a/include/asm-parisc/cacheflush.h b/include/asm-parisc/cacheflush.h
index 1bc3c83ee74b..c53af9ff41b5 100644
--- a/include/asm-parisc/cacheflush.h
+++ b/include/asm-parisc/cacheflush.h
@@ -183,4 +183,10 @@ flush_cache_page(struct vm_area_struct *vma, unsigned long vmaddr, unsigned long
183 __flush_cache_page(vma, vmaddr); 183 __flush_cache_page(vma, vmaddr);
184 184
185} 185}
186
187#ifdef CONFIG_DEBUG_RODATA
188void mark_rodata_ro(void);
186#endif 189#endif
190
191#endif /* _PARISC_CACHEFLUSH_H */
192
diff --git a/include/asm-parisc/pgtable.h b/include/asm-parisc/pgtable.h
index b4554711c3e7..4e34c6b44059 100644
--- a/include/asm-parisc/pgtable.h
+++ b/include/asm-parisc/pgtable.h
@@ -213,7 +213,7 @@ extern void *vmalloc_start;
213#define PAGE_COPY PAGE_EXECREAD 213#define PAGE_COPY PAGE_EXECREAD
214#define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED) 214#define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
215#define PAGE_KERNEL __pgprot(_PAGE_KERNEL) 215#define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
216#define PAGE_KERNEL_RO __pgprot(_PAGE_PRESENT | _PAGE_EXEC | _PAGE_READ | _PAGE_DIRTY | _PAGE_ACCESSED) 216#define PAGE_KERNEL_RO __pgprot(_PAGE_KERNEL & ~_PAGE_WRITE)
217#define PAGE_KERNEL_UNC __pgprot(_PAGE_KERNEL | _PAGE_NO_CACHE) 217#define PAGE_KERNEL_UNC __pgprot(_PAGE_KERNEL | _PAGE_NO_CACHE)
218#define PAGE_GATEWAY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | _PAGE_GATEWAY| _PAGE_READ) 218#define PAGE_GATEWAY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | _PAGE_GATEWAY| _PAGE_READ)
219#define PAGE_FLUSH __pgprot(_PAGE_FLUSH) 219#define PAGE_FLUSH __pgprot(_PAGE_FLUSH)