Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1237419 > unrolled thread

[PATCH] x86/mm: Set NX on gap between __ex_table and rodata

Started byStephen Smalley <sds@tycho.nsa.gov>
First post2015-10-01 15:10 +0200
Last post2015-10-02 09:50 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] x86/mm: Set NX on gap between __ex_table and rodata Stephen Smalley <sds@tycho.nsa.gov> - 2015-10-01 15:10 +0200
    Re: [PATCH] x86/mm: Set NX on gap between __ex_table and rodata Kees Cook <keescook@chromium.org> - 2015-10-01 18:40 +0200
    [tip:x86/urgent] x86/mm:   Set NX on gap between __ex_table and rodata tip-bot for Stephen Smalley <tipbot@zytor.com> - 2015-10-02 09:50 +0200

#1237419 — [PATCH] x86/mm: Set NX on gap between __ex_table and rodata

FromStephen Smalley <sds@tycho.nsa.gov>
Date2015-10-01 15:10 +0200
Subject[PATCH] x86/mm: Set NX on gap between __ex_table and rodata
Message-ID<qeLMv-53B-39@gated-at.bofh.it>
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>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1237560

FromKees Cook <keescook@chromium.org>
Date2015-10-01 18:40 +0200
Message-ID<qeP3I-1CP-29@gated-at.bofh.it>
In reply to#1237419
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1238018 — [tip:x86/urgent] x86/mm: Set NX on gap between __ex_table and rodata

Fromtip-bot for Stephen Smalley <tipbot@zytor.com>
Date2015-10-02 09:50 +0200
Subject[tip:x86/urgent] x86/mm: Set NX on gap between __ex_table and rodata
Message-ID<qf3gm-5mM-29@gated-at.bofh.it>
In reply to#1237419
Commit-ID:  ab76f7b4ab2397ffdd2f1eb07c55697d19991d10
Gitweb:     http://git.kernel.org/tip/ab76f7b4ab2397ffdd2f1eb07c55697d19991d10
Author:     Stephen Smalley <sds@tycho.nsa.gov>
AuthorDate: Thu, 1 Oct 2015 09:04:22 -0400
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 2 Oct 2015 09:21:06 +0200

x86/mm: Set NX on gap between __ex_table and rodata

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>
Cc: <stable@vger.kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Link: http://lkml.kernel.org/r/1443704662-3138-1-git-send-email-sds@tycho.nsa.gov
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 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();
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web