Message ID | f0bfc4b7ce6c8563bf0d5ef74af20b5d1edea66f.1519227112.git.khalid.aziz@oracle.com |
---|---|
State | Accepted |
Delegated to: | David Miller |
Headers | show |
Series | Application Data Integrity feature introduced by SPARC M7 | expand |
On 02/21/2018 09:15 AM, Khalid Aziz wrote: > +/* 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) Shouldn't this be defining # define VM_ARCH_CLEAR ARCH_VM_PKEY_FLAGS on x86? -- To unsubscribe from this list: send the line "unsubscribe sparclinux" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 03/05/2018 12:23 PM, Dave Hansen wrote: > On 02/21/2018 09:15 AM, Khalid Aziz wrote: >> +/* 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) > > Shouldn't this be defining > > # define VM_ARCH_CLEAR ARCH_VM_PKEY_FLAGS > > on x86? ARCH_VM_PKEY_FLAGS is used by x86 as well as powerpc. On those two architectures VM_FLAGS_CLEAR will end up being ARCH_VM_PKEY_FLAGS and thus current behavior will be retained. Defining VM_ARCH_CLEAR to be ARCH_VM_PKEY_FLAGS on x86 will just result in VM_FLAGS_CLEAR to be (ARCH_VM_PKEY_FLAGS | ARCH_VM_PKEY_FLAGS) which is superfluous. -- Khalid -- To unsubscribe from this list: send the line "unsubscribe sparclinux" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, 21 Feb 2018 10:15:50 -0700 Khalid Aziz <khalid.aziz@oracle.com> wrote: > 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> -- To unsubscribe from this list: send the line "unsubscribe sparclinux" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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); /* 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 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, * 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);