]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
mm: Clear arch specific VM flags on protection change
authorKhalid Aziz <khalid.aziz@oracle.com>
Wed, 21 Feb 2018 17:15:50 +0000 (10:15 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sun, 18 Mar 2018 14:38:47 +0000 (07:38 -0700)
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>
Reviewed-by: Anthony Yznaga <anthony.yznaga@oracle.com>
Acked-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/mm.h
mm/mprotect.c

index ad06d42adb1a2602094f894b69ed182cbac978fe..ae806dbc63eef412b3999b42e57fe19b8bd2e2bf 100644 (file)
@@ -287,6 +287,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..
index 088ea9c08678677fbd7d2318c22e67129b80e25a..c1d6af7455da542b9462cfc5ef8d64fa1d386a4f 100644 (file)
@@ -475,7 +475,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);