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


Groups > linux.kernel > #1739181

[PATCH v8 8/9] mm: Clear arch specific VM flags on protection change

From Khalid Aziz <khalid.aziz@oracle.com>
Newsgroups linux.kernel
Subject [PATCH v8 8/9] mm: Clear arch specific VM flags on protection change
Date 2017-09-25 19:00 +0200
Message-ID <utETF-zB-25@gated-at.bofh.it> (permalink)
References <utETE-zB-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


When protection bits are changed on a VMA, some of the architecture
specific flags should be cleared as well. An examples of this are the
PKEY flags on x86. This patch expands the current code that clears
PKEY flags for x86, to support similar functionality for other
architectures as well.

Signed-off-by: Khalid Aziz <khalid.aziz@oracle.com>
Cc: Khalid Aziz <khalid@gonehiking.org>
---
v7:
	- new patch

 include/linux/mm.h | 6 ++++++
 mm/mprotect.c      | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index c1f6c95f3496..cbb21facce6b 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -271,6 +271,12 @@ extern unsigned int kobjsize(const void *objp);
 /* This mask is used to clear all the VMA flags used by mlock */
 #define VM_LOCKED_CLEAR_MASK	(~(VM_LOCKED | VM_LOCKONFAULT))
 
+/* Arch-specific flags to clear when updating VM flags on protection change */
+#ifndef VM_ARCH_CLEAR
+# define VM_ARCH_CLEAR	VM_NONE
+#endif
+#define VM_FLAGS_CLEAR	(ARCH_VM_PKEY_FLAGS | VM_ARCH_CLEAR)
+
 /*
  * mapping from the currently active vm_flags protection bits (the
  * low four bits) to a page protection mask..
diff --git a/mm/mprotect.c b/mm/mprotect.c
index 4f0e46bb1797..85b65b3a823d 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -453,7 +453,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len,
 		 * cleared from the VMA.
 		 */
 		mask_off_old_flags = VM_READ | VM_WRITE | VM_EXEC |
-					ARCH_VM_PKEY_FLAGS;
+					VM_FLAGS_CLEAR;
 
 		new_vma_pkey = arch_override_mprotect_pkey(vma, prot, pkey);
 		newflags = calc_vm_prot_bits(prot, new_vma_pkey);
-- 
2.11.0

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH v8 0/9] Application Data Integrity feature introduced by SPARC M7 Khalid Aziz <khalid.aziz@oracle.com> - 2017-09-25 19:00 +0200
  [PATCH v8 7/9] mm: Add address parameter to arch_validate_prot() Khalid Aziz <khalid.aziz@oracle.com> - 2017-09-25 19:00 +0200
  [PATCH v8 5/9] sparc64: Add handler for "Memory Corruption Detected" trap Khalid Aziz <khalid.aziz@oracle.com> - 2017-09-25 19:00 +0200
  [PATCH v8 4/9] sparc64: Add HV fault type handlers for ADI related faults Khalid Aziz <khalid.aziz@oracle.com> - 2017-09-25 19:00 +0200
  [PATCH v8 1/9] signals, sparc: Add signal codes for ADI violations Khalid Aziz <khalid.aziz@oracle.com> - 2017-09-25 19:00 +0200
  [PATCH v8 6/9] sparc64: Add auxiliary vectors to report platform ADI properties Khalid Aziz <khalid.aziz@oracle.com> - 2017-09-25 19:00 +0200
  [PATCH v8 2/9] mm, swap: Add infrastructure for saving page metadata as well on swap Khalid Aziz <khalid.aziz@oracle.com> - 2017-09-25 19:00 +0200
  [PATCH v8 8/9] mm: Clear arch specific VM flags on protection change Khalid Aziz <khalid.aziz@oracle.com> - 2017-09-25 19:00 +0200

csiph-web