]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
sparc64: Do not retain old VM_SPARC_ADI flag when protection changes on page
authorKhalid Aziz <khalid.aziz@oracle.com>
Tue, 7 Mar 2017 18:26:10 +0000 (11:26 -0700)
committerChuck Anderson <chuck.anderson@oracle.com>
Thu, 6 Apr 2017 07:13:43 +0000 (00:13 -0700)
When protection on a memory page is changed with mprotect(), old
arch-specific VM flags on the page are retained. This patch clears
old VM_SPARC_ADI flag when protection is changed since mprotect() is
potentially being invoked to disable ADI on the page. This code will
add VM_SPARC_ADI flag back if the new protection includes it.

Orabug: 25641371

Signed-off-by: Khalid Aziz <khalid.aziz@oracle.com>
Signed-off-by: Allen Pais <allen.pais@oracle.com>
include/linux/mm.h
mm/mprotect.c

index 1f41995d06f30a405246ae2b75f38ff551e8cf1d..c7d1f776cc7d795a2fe92830537252ffc80e9500 100644 (file)
@@ -165,6 +165,7 @@ extern unsigned int kobjsize(const void *objp);
 # define VM_GROWSUP    VM_ARCH_1
 #elif defined(CONFIG_SPARC64)
 # define VM_SPARC_ADI  VM_ARCH_1       /* Uses ADI tag for access control */
+# define VM_ARCH_CLEAR VM_SPARC_ADI
 #elif !defined(CONFIG_MMU)
 # define VM_MAPPED_COPY        VM_ARCH_1       /* T if mapped copy of data (nommu mmap) */
 #endif
@@ -200,6 +201,11 @@ extern unsigned int kobjsize(const void *objp);
 /* This mask defines which mm->def_flags a process can inherit its parent */
 #define VM_INIT_DEF_MASK       VM_NOHUGEPAGE
 
+/* Arch-specific flags to clear when updating VM flags on protection change */
+#ifndef VM_ARCH_CLEAR
+# define VM_ARCH_CLEAR VM_NONE
+#endif
+
 /*
  * mapping from the currently active vm_flags protection bits (the
  * low four bits) to a page protection mask..
index 88584838e7046bec724d68c0cafcd94eec65a040..826bb094c84d919bf8aa87cdecf7eac91495966e 100644 (file)
@@ -396,7 +396,8 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
                /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
 
                newflags = vm_flags;
-               newflags |= (vma->vm_flags & ~(VM_READ | VM_WRITE | VM_EXEC));
+               newflags |= (vma->vm_flags & ~(VM_READ | VM_WRITE | VM_EXEC |
+                               VM_ARCH_CLEAR));
 
                /* newflags >> 4 shift VM_MAY% in place of VM_% */
                if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {