lkml.org 
[lkml]   [2018]   [Aug]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH 7/7] x86/mm/pageattr: Remove implicit NX behavior
From
Date

From: Dave Hansen <dave.hansen@linux.intel.com>

This is a cleanup. There should be functional changes in this patch.

The pageattr code has the ability to find and change aliases
mappings. It does this for requests by default unless the
page protections being modified contain only the NX bit.

But, this behavior is rather obscure and buried very deep
within the infrastructure. Rather than doing it implicitly
from NX, use the new CPA_NO_CHECK_ALIAS to do it more
explicitly from the call site where NX is set.

Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Kees Cook <keescook@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Hugh Dickins <hughd@google.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Andi Kleen <ak@linux.intel.com>
---

b/arch/x86/mm/pageattr.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff -puN arch/x86/mm/pageattr.c~x86-pageattr-nx arch/x86/mm/pageattr.c
--- a/arch/x86/mm/pageattr.c~x86-pageattr-nx 2018-08-02 15:04:48.032475796 -0700
+++ b/arch/x86/mm/pageattr.c 2018-08-02 15:04:48.036475796 -0700
@@ -1485,8 +1485,6 @@ static int change_page_attr_set_clr(unsi
if (in_flag & (CPA_ARRAY | CPA_PAGES_ARRAY))
cpa.flags |= in_flag;

- /* No alias checking for _NX bit modifications */
- checkalias = (pgprot_val(mask_set) | pgprot_val(mask_clr)) != _PAGE_NX;
/* Never check aliases if the caller asks for it explicitly: */
if (checkalias && (in_flag & CPA_NO_CHECK_ALIAS))
checkalias = 0;
@@ -1750,7 +1748,9 @@ int set_memory_x(unsigned long addr, int
if (!(__supported_pte_mask & _PAGE_NX))
return 0;

- return change_page_attr_clear(&addr, numpages, __pgprot(_PAGE_NX), 0);
+ /* NX is not required to be consistent across aliases. */
+ return change_page_attr_clear(&addr, numpages, __pgprot(_PAGE_NX),
+ CPA_NO_CHECK_ALIAS);
}
EXPORT_SYMBOL(set_memory_x);

@@ -1759,7 +1759,9 @@ int set_memory_nx(unsigned long addr, in
if (!(__supported_pte_mask & _PAGE_NX))
return 0;

- return change_page_attr_set(&addr, numpages, __pgprot(_PAGE_NX), 0);
+ /* NX is not required to be consistent across aliases. */
+ return change_page_attr_set(&addr, numpages, __pgprot(_PAGE_NX),
+ CPA_NO_CHECK_ALIAS);
}
EXPORT_SYMBOL(set_memory_nx);

_
\
 
 \ /
  Last update: 2018-08-03 00:59    [W:0.140 / U:1.928 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site