From: Ingo Molnar <mingo@kernel.org>
To: Stephen Smalley <sds@tycho.nsa.gov>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
keescook@chromium.org, Borislav Petkov <bp@alien8.de>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Andy Lutomirski <luto@kernel.org>,
Denys Vlasenko <dvlasenk@redhat.com>,
Brian Gerst <brgerst@gmail.com>
Subject: Re: [RFC][PATCH] x86/mm: warn on W+x mappings
Date: Fri, 2 Oct 2015 09:37:09 +0200 [thread overview]
Message-ID: <20151002073708.GB5035@gmail.com> (raw)
In-Reply-To: <1443716923-6072-1-git-send-email-sds@tycho.nsa.gov>
* Stephen Smalley <sds@tycho.nsa.gov> wrote:
> + st.check_wx = checkwx;
> + if (checkwx) {
> + pr_info("Checking for W+x mappings\n");
> + st.found_wx = false;
> + }
> +
> for (i = 0; i < PTRS_PER_PGD; i++) {
> st.current_address = normalize_addr(i * PGD_LEVEL_MULT);
> if (!pgd_none(*start)) {
> @@ -378,6 +395,18 @@ void ptdump_walk_pgd_level(struct seq_file *m, pgd_t *pgd)
> /* Flush out the last page */
> st.current_address = normalize_addr(PTRS_PER_PGD*PGD_LEVEL_MULT);
> note_page(m, &st, __pgprot(0), 0);
> + if (checkwx && st.found_wx)
> + pr_warn("Found W+x mappings. Please fix.\n");
So I like the patch, except the way it presents failures:
please generate any printks() only after the check has been performed, not before
it. There should be a single line printed in the 'test successful' case:
pr_info("x86/mm: Checked W+X mappings: passed, no W+X pages found.\n");
In the failure case there should be printk()s generated at the first point of
violation:
+ pgprotval_t pr = pgprot_val(st->current_prot);
+ bool savedmesg = st->to_dmesg;
+
+ if (st->check_wx && (pr & _PAGE_RW) && !(pr & _PAGE_NX)) {
+ st->to_dmesg = true;
+ st->found_wx = true;
+ }
via something like:
WARN_ONCE(1, "x86/mm: Found insecure W+X mapping at address %p/%pS\n", addr, addr);
i.e. output the address and the symbolic name as well. Only generate a single
warning - we expect the normal kernel to be entirely warnings-free.
and then print the number of pages with bad mappings in the 'result' line:
pr_info("x86/mm: Checked W+X mappings: FAILED, %ld W+X pages found.\n", nr_failures);
Thanks,
Ingo
prev parent reply other threads:[~2015-10-02 7:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-01 16:28 [RFC][PATCH] x86/mm: warn on W+x mappings Stephen Smalley
2015-10-01 19:24 ` Kees Cook
2015-10-01 19:41 ` Borislav Petkov
2015-10-02 7:26 ` Ingo Molnar
2015-10-02 8:02 ` Borislav Petkov
2015-10-03 7:50 ` Ingo Molnar
2015-10-03 9:01 ` Borislav Petkov
2015-10-02 7:37 ` Ingo Molnar [this message]
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=20151002073708.GB5035@gmail.com \
--to=mingo@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=bp@alien8.de \
--cc=brgerst@gmail.com \
--cc=dvlasenk@redhat.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=sds@tycho.nsa.gov \
--cc=x86@kernel.org \
/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