Skip to content

Commit

Permalink
arm64: add check_wx_pages debugfs for CHECK_WX
Browse files Browse the repository at this point in the history
follow the suggestion from
KSPP#35

Signed-off-by: Phong Tran <tranmanphong@gmail.com>
  • Loading branch information
phongt authored and intel-lab-lkp committed Mar 7, 2020
1 parent 9c814a9 commit c423733
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion arch/arm64/Kconfig.debug
Expand Up @@ -48,7 +48,8 @@ config DEBUG_WX
of other unfixed kernel bugs easier.

There is no runtime or memory usage effect of this option
once the kernel has booted up - it's a one time check.
once the kernel has booted up - it's a one time check and
can be checked by echo "1" to "check_wx_pages" debugfs in runtime.

If in doubt, say "Y".

Expand Down
2 changes: 2 additions & 0 deletions arch/arm64/include/asm/ptdump.h
Expand Up @@ -24,9 +24,11 @@ struct ptdump_info {
void ptdump_walk(struct seq_file *s, struct ptdump_info *info);
#ifdef CONFIG_PTDUMP_DEBUGFS
void ptdump_debugfs_register(struct ptdump_info *info, const char *name);
int ptdump_check_wx_init(void);
#else
static inline void ptdump_debugfs_register(struct ptdump_info *info,
const char *name) { }
static inline int ptdump_check_wx_init(void) { return 0; }
#endif
void ptdump_check_wx(void);
#endif /* CONFIG_PTDUMP_CORE */
Expand Down
1 change: 1 addition & 0 deletions arch/arm64/mm/dump.c
Expand Up @@ -378,6 +378,7 @@ static int ptdump_init(void)
#endif
ptdump_initialize();
ptdump_debugfs_register(&kernel_ptdump_info, "kernel_page_tables");
ptdump_check_wx_init();
return 0;
}
device_initcall(ptdump_init);
18 changes: 18 additions & 0 deletions arch/arm64/mm/ptdump_debugfs.c
Expand Up @@ -20,3 +20,21 @@ void ptdump_debugfs_register(struct ptdump_info *info, const char *name)
{
debugfs_create_file(name, 0400, NULL, info, &ptdump_fops);
}

static int check_wx_debugfs_set(void *data, u64 val)
{
if (val != 1ULL)
return -EINVAL;

ptdump_check_wx();

return 0;
}

DEFINE_SIMPLE_ATTRIBUTE(check_wx_fops, NULL, check_wx_debugfs_set, "%llu\n");

int ptdump_check_wx_init(void)
{
return debugfs_create_file("check_wx_pages", 0200, NULL,
NULL, &check_wx_fops) ? 0 : -ENOMEM;
}

0 comments on commit c423733

Please sign in to comment.