linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Stephen Smalley <sds@tycho.nsa.gov>
Cc: "x86@kernel.org" <x86@kernel.org>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] x86/mm: Set NX on gap between __ex_table and rodata
Date: Thu, 1 Oct 2015 09:35:09 -0700	[thread overview]
Message-ID: <CAGXu5j+KA0-HDAU_eWKdQEbyqoHMo6rZ0Sh87mWTQidQVZ4fgg@mail.gmail.com> (raw)
In-Reply-To: <1443704662-3138-1-git-send-email-sds@tycho.nsa.gov>

On Thu, Oct 1, 2015 at 6:04 AM, Stephen Smalley <sds@tycho.nsa.gov> wrote:
> Unused space between the end of __ex_table and the start of rodata
> can be left W+x in the kernel page tables.  Extend the setting
> of the NX bit to cover this gap by starting from text_end rather than
> rodata_start.
>
> Before:
> ---[ High Kernel Mapping ]---
> 0xffffffff80000000-0xffffffff81000000          16M                               pmd
> 0xffffffff81000000-0xffffffff81600000           6M     ro         PSE     GLB x  pmd
> 0xffffffff81600000-0xffffffff81754000        1360K     ro                 GLB x  pte
> 0xffffffff81754000-0xffffffff81800000         688K     RW                 GLB x  pte
> 0xffffffff81800000-0xffffffff81a00000           2M     ro         PSE     GLB NX pmd
> 0xffffffff81a00000-0xffffffff81b3b000        1260K     ro                 GLB NX pte
> 0xffffffff81b3b000-0xffffffff82000000        4884K     RW                 GLB NX pte
> 0xffffffff82000000-0xffffffff82200000           2M     RW         PSE     GLB NX pmd
> 0xffffffff82200000-0xffffffffa0000000         478M                               pmd
>
> After:
> ---[ High Kernel Mapping ]---
> 0xffffffff80000000-0xffffffff81000000          16M                               pmd
> 0xffffffff81000000-0xffffffff81600000           6M     ro         PSE     GLB x  pmd
> 0xffffffff81600000-0xffffffff81754000        1360K     ro                 GLB x  pte
> 0xffffffff81754000-0xffffffff81800000         688K     RW                 GLB NX pte
> 0xffffffff81800000-0xffffffff81a00000           2M     ro         PSE     GLB NX pmd
> 0xffffffff81a00000-0xffffffff81b3b000        1260K     ro                 GLB NX pte
> 0xffffffff81b3b000-0xffffffff82000000        4884K     RW                 GLB NX pte
> 0xffffffff82000000-0xffffffff82200000           2M     RW         PSE     GLB NX pmd
> 0xffffffff82200000-0xffffffffa0000000         478M                               pmd
>
> Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>

Acked-by: Kees Cook <keescook@chromium.org>

-Kees

> ---
>  arch/x86/mm/init_64.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
> index 30564e2..df48430 100644
> --- a/arch/x86/mm/init_64.c
> +++ b/arch/x86/mm/init_64.c
> @@ -1132,7 +1132,7 @@ void mark_rodata_ro(void)
>          * has been zapped already via cleanup_highmem().
>          */
>         all_end = roundup((unsigned long)_brk_end, PMD_SIZE);
> -       set_memory_nx(rodata_start, (all_end - rodata_start) >> PAGE_SHIFT);
> +       set_memory_nx(text_end, (all_end - text_end) >> PAGE_SHIFT);
>
>         rodata_test();
>
> --
> 2.1.0
>



-- 
Kees Cook
Chrome OS Security

  reply	other threads:[~2015-10-01 16:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-01 13:04 [PATCH] x86/mm: Set NX on gap between __ex_table and rodata Stephen Smalley
2015-10-01 16:35 ` Kees Cook [this message]
2015-10-02  7:45 ` [tip:x86/urgent] " tip-bot for Stephen Smalley

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=CAGXu5j+KA0-HDAU_eWKdQEbyqoHMo6rZ0Sh87mWTQidQVZ4fgg@mail.gmail.com \
    --to=keescook@chromium.org \
    --cc=linux-kernel@vger.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;
as well as URLs for NNTP newsgroup(s).