Skip to content

Commit

Permalink
ptdump: add check_wx_pages debugfs for CHECK_WX
Browse files Browse the repository at this point in the history
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
  • Loading branch information
chleroy committed Jan 8, 2024
1 parent eb4f331 commit ba6351c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions mm/ptdump.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0

#include <linux/pagewalk.h>
#include <linux/debugfs.h>
#include <linux/ptdump.h>
#include <linux/kasan.h>

Expand Down Expand Up @@ -163,3 +164,24 @@ void ptdump_walk_pgd(struct ptdump_state *st, struct mm_struct *mm, pgd_t *pgd)
/* Flush out the last page */
st->note_page(st, 0, -1, 0);
}

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");

static int ptdump_debugfs_init(void)
{
debugfs_create_file("check_wx_pages", 0200, NULL, NULL, &check_wx_fops);

return 0;
}

device_initcall(ptdump_debugfs_init);

0 comments on commit ba6351c

Please sign in to comment.