From: Russell Currey <ruscur@russell.cc>
To: Christophe Leroy <christophe.leroy@c-s.fr>,
linuxppc-dev@lists.ozlabs.org
Cc: ajd@linux.ibm.com, npiggin@gmail.com, joel@jms.id.au,
rashmica.g@gmail.com, dja@axtens.net
Subject: Re: [PATCH v3 3/4] powerpc/mm/ptdump: debugfs handler for W+X checks at runtime
Date: Mon, 14 Oct 2019 13:36:52 +1100 [thread overview]
Message-ID: <764cfbeb7233e3532a89820ff7cb242531aa63ea.camel@russell.cc> (raw)
In-Reply-To: <665bacec-036f-f392-7e0f-95a57b0a7d22@c-s.fr>
On Tue, 2019-10-08 at 08:21 +0200, Christophe Leroy wrote:
>
> Le 04/10/2019 à 09:50, Russell Currey a écrit :
> > Very rudimentary, just
> >
> > echo 1 > [debugfs]/check_wx_pages
> >
> > and check the kernel log. Useful for testing strict module RWX.
> >
> > Also fixed a typo.
> >
> > Signed-off-by: Russell Currey <ruscur@russell.cc>
> > ---
> > arch/powerpc/mm/ptdump/ptdump.c | 31 +++++++++++++++++++++++++---
> > ---
> > 1 file changed, 25 insertions(+), 6 deletions(-)
> >
> > diff --git a/arch/powerpc/mm/ptdump/ptdump.c
> > b/arch/powerpc/mm/ptdump/ptdump.c
> > index 2f9ddc29c535..0547cd9f264e 100644
> > --- a/arch/powerpc/mm/ptdump/ptdump.c
> > +++ b/arch/powerpc/mm/ptdump/ptdump.c
> > @@ -4,7 +4,7 @@
> > *
> > * This traverses the kernel pagetables and dumps the
> > * information about the used sections of memory to
> > - * /sys/kernel/debug/kernel_pagetables.
> > + * /sys/kernel/debug/kernel_page_tables.
> > *
> > * Derived from the arm64 implementation:
> > * Copyright (c) 2014, The Linux Foundation, Laura Abbott.
> > @@ -409,16 +409,35 @@ void ptdump_check_wx(void)
> > else
> > pr_info("Checked W+X mappings: passed, no W+X pages
> > found\n");
> > }
> > +
> > +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");
> > #endif
> >
> > static int ptdump_init(void)
> > {
> > - struct dentry *debugfs_file;
> > -
> > populate_markers();
> > build_pgtable_complete_mask();
> > - debugfs_file = debugfs_create_file("kernel_page_tables", 0400,
> > NULL,
> > - NULL, &ptdump_fops);
> > - return debugfs_file ? 0 : -ENOMEM;
> > +
> > + if (!debugfs_create_file("kernel_page_tables", 0400, NULL,
> > + NULL, &ptdump_fops))
> > + return -ENOMEM;
> > +
> > +#ifdef CONFIG_PPC_DEBUG_WX
> > + if (!debugfs_create_file("check_wx_pages", 0200, NULL,
> > + NULL, &check_wx_fops))
> > + return -ENOMEM;
> > +#endif
>
> The above seems to be completely independant from everything else in
> ptdump_init().
>
> Could we avoid this #ifdef block inside ptdump_init() by creating a
> selfstanding device_initcall() for that through a function called
> ptdump_check_wx_init() defined inside the same #ifdef block as
> ptdump_check_wx() ?
Yes that would be nicer, thanks
>
> Christophe
>
> > +
> > + return 0;
> > }
> > device_initcall(ptdump_init);
> >
next prev parent reply other threads:[~2019-10-14 2:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-04 7:50 [PATCH v3 0/4] Implement STRICT_MODULE_RWX for powerpc Russell Currey
2019-10-04 7:50 ` [PATCH v3 1/4] powerpc/mm: Implement set_memory() routines Russell Currey
2019-10-23 2:56 ` Michael Ellerman
2019-10-04 7:50 ` [PATCH v3 2/4] powerpc/kprobes: Mark newly allocated probes as RO Russell Currey
2019-10-14 2:22 ` Andrew Donnellan
2019-10-04 7:50 ` [PATCH v3 3/4] powerpc/mm/ptdump: debugfs handler for W+X checks at runtime Russell Currey
2019-10-08 1:59 ` Daniel Axtens
2019-10-08 6:21 ` Christophe Leroy
2019-10-14 2:36 ` Russell Currey [this message]
2019-10-04 7:50 ` [PATCH v3 4/4] powerpc: Enable STRICT_MODULE_RWX Russell Currey
2019-10-10 13:13 ` Daniel Axtens
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=764cfbeb7233e3532a89820ff7cb242531aa63ea.camel@russell.cc \
--to=ruscur@russell.cc \
--cc=ajd@linux.ibm.com \
--cc=christophe.leroy@c-s.fr \
--cc=dja@axtens.net \
--cc=joel@jms.id.au \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=npiggin@gmail.com \
--cc=rashmica.g@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).