linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Khalid Aziz <khalid.aziz@oracle.com>
To: akpm@linux-foundation.org, davem@davemloft.net,
	dave.hansen@linux.intel.com
Cc: Khalid Aziz <khalid.aziz@oracle.com>,
	mhocko@suse.com, jack@suse.cz, kirill.shutemov@linux.intel.com,
	ross.zwisler@linux.intel.com, lstoakes@gmail.com,
	dave.jiang@intel.com, willy@infradead.org, hughd@google.com,
	ying.huang@intel.com, n-horiguchi@ah.jp.nec.com,
	heiko.carstens@de.ibm.com, mgorman@suse.de, aarcange@redhat.com,
	ak@linux.intel.com, aneesh.kumar@linux.vnet.ibm.com,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	sparclinux@vger.kernel.org, Khalid Aziz <khalid@gonehiking.org>
Subject: [PATCH v10 08/10] mm: Clear arch specific VM flags on protection change
Date: Wed, 15 Nov 2017 15:46:23 -0700	[thread overview]
Message-ID: <e4656969f15fe0b43135b6e3f301695b77c885fc.1510768775.git.khalid.aziz@oracle.com> (raw)
In-Reply-To: <cover.1510768775.git.khalid.aziz@oracle.com>
In-Reply-To: <cover.1510768775.git.khalid.aziz@oracle.com>

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 43edf659453b..f97bc6184c52 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -277,6 +277,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 1e0d9cb024c8..a071f72309c0 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -468,7 +468,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

  parent reply	other threads:[~2017-11-15 22:49 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-15 22:46 [PATCH v10 00/10] Application Data Integrity feature introduced by SPARC M7 Khalid Aziz
2017-11-15 22:46 ` [PATCH v10 01/10] signals, sparc: Add signal codes for ADI violations Khalid Aziz
2017-11-15 22:46 ` [PATCH v10 02/10] mm, swap: Add infrastructure for saving page metadata as well on swap Khalid Aziz
2017-11-15 22:46 ` [PATCH v10 03/10] sparc64: Add support for ADI register fields, ASIs and traps Khalid Aziz
2017-11-15 22:46 ` [PATCH v10 04/10] sparc64: Add HV fault type handlers for ADI related faults Khalid Aziz
2017-11-15 22:46 ` [PATCH v10 05/10] sparc64: Add handler for "Memory Corruption Detected" trap Khalid Aziz
2017-11-15 22:46 ` [PATCH v10 06/10] sparc64: Add auxiliary vectors to report platform ADI properties Khalid Aziz
2017-11-15 22:46 ` [PATCH v10 07/10] mm: Add address parameter to arch_validate_prot() Khalid Aziz
2017-11-15 22:46 ` Khalid Aziz [this message]
2017-11-15 22:46 ` [PATCH v10 09/10] mm: Allow arch code to override copy_highpage() Khalid Aziz
2017-11-15 22:46 ` [PATCH v10 10/10] sparc64: Add support for ADI (Application Data Integrity) Khalid Aziz
2017-11-17  2:14 ` [PATCH RESEND v10 00/10] Application Data Integrity feature introduced by SPARC M7 Anthony Yznaga

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=e4656969f15fe0b43135b6e3f301695b77c885fc.1510768775.git.khalid.aziz@oracle.com \
    --to=khalid.aziz@oracle.com \
    --cc=aarcange@redhat.com \
    --cc=ak@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=dave.jiang@intel.com \
    --cc=davem@davemloft.net \
    --cc=heiko.carstens@de.ibm.com \
    --cc=hughd@google.com \
    --cc=jack@suse.cz \
    --cc=khalid@gonehiking.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lstoakes@gmail.com \
    --cc=mgorman@suse.de \
    --cc=mhocko@suse.com \
    --cc=n-horiguchi@ah.jp.nec.com \
    --cc=ross.zwisler@linux.intel.com \
    --cc=sparclinux@vger.kernel.org \
    --cc=willy@infradead.org \
    --cc=ying.huang@intel.com \
    /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).