aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKhalid Aziz <khalid.aziz@oracle.com>2018-02-21 12:15:50 -0500
committerDavid S. Miller <davem@davemloft.net>2018-03-18 10:38:47 -0400
commit2c2d57b5e769956fb36581e0d3cccdb5ea68038f (patch)
tree339cc77f5489da03b12eb478315429f2c60bcf9d
parent9035cf9a97e429e6b5291841da81c433879f5658 (diff)
mm: Clear arch specific VM flags on protection change
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>
-rw-r--r--include/linux/mm.h6
-rw-r--r--mm/mprotect.c2
2 files changed, 7 insertions, 1 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h
index ad06d42adb1a..ae806dbc63ee 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -287,6 +287,12 @@ extern unsigned int kobjsize(const void *objp);
287/* This mask is used to clear all the VMA flags used by mlock */ 287/* This mask is used to clear all the VMA flags used by mlock */
288#define VM_LOCKED_CLEAR_MASK (~(VM_LOCKED | VM_LOCKONFAULT)) 288#define VM_LOCKED_CLEAR_MASK (~(VM_LOCKED | VM_LOCKONFAULT))
289 289
290/* Arch-specific flags to clear when updating VM flags on protection change */
291#ifndef VM_ARCH_CLEAR
292# define VM_ARCH_CLEAR VM_NONE
293#endif
294#define VM_FLAGS_CLEAR (ARCH_VM_PKEY_FLAGS | VM_ARCH_CLEAR)
295
290/* 296/*
291 * mapping from the currently active vm_flags protection bits (the 297 * mapping from the currently active vm_flags protection bits (the
292 * low four bits) to a page protection mask.. 298 * low four bits) to a page protection mask..
diff --git a/mm/mprotect.c b/mm/mprotect.c
index 088ea9c08678..c1d6af7455da 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -475,7 +475,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len,
475 * cleared from the VMA. 475 * cleared from the VMA.
476 */ 476 */
477 mask_off_old_flags = VM_READ | VM_WRITE | VM_EXEC | 477 mask_off_old_flags = VM_READ | VM_WRITE | VM_EXEC |
478 ARCH_VM_PKEY_FLAGS; 478 VM_FLAGS_CLEAR;
479 479
480 new_vma_pkey = arch_override_mprotect_pkey(vma, prot, pkey); 480 new_vma_pkey = arch_override_mprotect_pkey(vma, prot, pkey);
481 newflags = calc_vm_prot_bits(prot, new_vma_pkey); 481 newflags = calc_vm_prot_bits(prot, new_vma_pkey);