x86, kernel: make X86_PTDUMP a tristate
PATCH 1/1 x86, kernel: make X86_PTDUMP a tristate
Being able to examine page tables is handy, so make this a module that can be loaded as needed.
Signed-off-by Kees Cook <[email protected]>
--- arch/x86/Kconfig.debug | 2 +- arch/x86/mm/Makefile | 1 + arch/x86/mm/debug_pagetables.c | 46 ++++++++++++++++++++++++++++++++++++++++++ arch/x86/mm/dump_pagetables.c | 34 ++----------------------------- 4 files changed, 50 insertions(+), 33 deletions(-) create mode 100644 arch/x86/mm/debug_pagetables.c
arch/x86/Kconfig.debug +1 -1
@@ -69,7 +69,7 @@ config X86_PTDUMP_CORE def_bool n config X86_PTDUMP - bool "Export kernel pagetable layout to userspace via debugfs" + tristate "Export kernel pagetable layout to userspace via debugfs" depends on DEBUG_KERNEL select DEBUG_FS select X86_PTDUMP_CORE
arch/x86/mm/Makefile +1 -0
@@ -15,6 +15,7 @@ obj-$(CONFIG_X86_32) += pgtable_32.o iomap_32.o obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o obj-$(CONFIG_X86_PTDUMP_CORE) += dump_pagetables.o +obj-$(CONFIG_X86_PTDUMP) += debug_pagetables.o obj-$(CONFIG_HIGHMEM) += highmem_32.o
arch/x86/mm/debug_pagetables.c new file +46 -0
46 lines not on this page · raw message
arch/x86/mm/dump_pagetables.c +2 -32
@@ -426,38 +426,15 @@ void ptdump_walk_pgd_level(struct seq_file *m, pgd_t *pgd) {ptdump_walk_pgd_level_core (m, pgd, false); } +EXPORT_SYMBOL_GPL (ptdump_walk_pgd_level);void ptdump_walk_pgd_level_checkwx (void ) {ptdump_walk_pgd_level_core (NULL ,NULL , true); } -#ifdef CONFIG_X86_PTDUMP -static int ptdump_show (struct seq_file *m,void *v) +static int __init pt_dump_init (void ) { -ptdump_walk_pgd_level (m,NULL ); -return 0 ; -} - -static int ptdump_open (struct inode *inode,struct file *filp) -{ -return single_open (filp, ptdump_show,NULL ); -} - -static const struct file_operations ptdump_fops = { - .open = ptdump_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; -#endif - -static int pt_dump_init (void ) -{ -#ifdef CONFIG_X86_PTDUMP -struct dentry *pe; -#endif -#ifdef CONFIG_X86_32 /* Not a compile-time constant on x86-32 */ address_markers[VMALLOC_START_NR ].start_address =VMALLOC_START ;
@@ -468,13 +445,6 @@ static int pt_dump_init(void) address_markers[FIXADDR_START_NR ].start_address =FIXADDR_START ;#endif -#ifdef CONFIG_X86_PTDUMP - pe =debugfs_create_file ("kernel_page_tables" ,0600 ,NULL ,NULL , - &ptdump_fops); -if (!pe) -return -ENOMEM ; -#endif -return 0 ; }
Signature · 6 lines
1.9.1 -- Kees Cook Chrome OS Security
tip-bot for Kees Cook
merge bot[tip:x86/mm] x86/mm: Turn CONFIG_X86_PTDUMP into a module
x86/mm: Turn CONFIG_X86_PTDUMP into a module
Commit-ID: 8609d1b5daa36350e020e737946c40887af1743a Gitweb: http://git.kernel.org/tip/8609d1b5daa36350e020e737946c40887af1743a Author: Kees Cook <[email protected]> AuthorDate: Thu, 19 Nov 2015 17:07:55 -0800 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 23 Nov 2015 10:50:13 +0100
x86/mm: Turn CONFIG_X86_PTDUMP into a module
Being able to examine page tables is handy, so make this a module that can be loaded as needed.
Signed-off-by Kees Cook <[email protected]>
Cc Andrey Ryabinin <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc Boris Ostrovsky <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Brian Gerst <[email protected]>
Cc Denys Vlasenko <[email protected]>
Cc H. Peter Anvin <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephen Smalley <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Toshi Kani <[email protected]>
Cc Vladimir Murzin <[email protected]>
Cc Will Deacon <[email protected]>
Signed-off-by Ingo Molnar <[email protected]>
--- arch/x86/Kconfig.debug | 2 +- arch/x86/mm/Makefile | 1 + arch/x86/mm/debug_pagetables.c | 46 ++++++++++++++++++++++++++++++++++++++++++ arch/x86/mm/dump_pagetables.c | 34 ++----------------------------- 4 files changed, 50 insertions(+), 33 deletions(-)
arch/x86/Kconfig.debug +1 -1
@@ -69,7 +69,7 @@ config X86_PTDUMP_CORE def_bool n config X86_PTDUMP - bool "Export kernel pagetable layout to userspace via debugfs" + tristate "Export kernel pagetable layout to userspace via debugfs" depends on DEBUG_KERNEL select DEBUG_FS select X86_PTDUMP_CORE
arch/x86/mm/Makefile +1 -0
@@ -15,6 +15,7 @@ obj-$(CONFIG_X86_32) += pgtable_32.o iomap_32.o obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o obj-$(CONFIG_X86_PTDUMP_CORE) += dump_pagetables.o +obj-$(CONFIG_X86_PTDUMP) += debug_pagetables.o obj-$(CONFIG_HIGHMEM) += highmem_32.o
arch/x86/mm/debug_pagetables.c new file +46 -0
46 lines not on this page · raw message
arch/x86/mm/dump_pagetables.c +2 -32
@@ -426,38 +426,15 @@ void ptdump_walk_pgd_level(struct seq_file *m, pgd_t *pgd) {ptdump_walk_pgd_level_core (m, pgd, false); } +EXPORT_SYMBOL_GPL (ptdump_walk_pgd_level);void ptdump_walk_pgd_level_checkwx (void ) {ptdump_walk_pgd_level_core (NULL ,NULL , true); } -#ifdef CONFIG_X86_PTDUMP -static int ptdump_show (struct seq_file *m,void *v) +static int __init pt_dump_init (void ) { -ptdump_walk_pgd_level (m,NULL ); -return 0 ; -} - -static int ptdump_open (struct inode *inode,struct file *filp) -{ -return single_open (filp, ptdump_show,NULL ); -} - -static const struct file_operations ptdump_fops = { - .open = ptdump_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; -#endif - -static int pt_dump_init (void ) -{ -#ifdef CONFIG_X86_PTDUMP -struct dentry *pe; -#endif -#ifdef CONFIG_X86_32 /* Not a compile-time constant on x86-32 */ address_markers[VMALLOC_START_NR ].start_address =VMALLOC_START ;
@@ -468,13 +445,6 @@ static int pt_dump_init(void) address_markers[FIXADDR_START_NR ].start_address =FIXADDR_START ;#endif -#ifdef CONFIG_X86_PTDUMP - pe =debugfs_create_file ("kernel_page_tables" ,0600 ,NULL ,NULL , - &ptdump_fops); -if (!pe) -return -ENOMEM ; -#endif -return 0 ; }