Re: [PATCH v7 24/41] mm: Don't allow write GUPs to shadow stack memory
From: Deepak Gupta <hidden>
Date: 2023-03-17 17:06:08
Also in:
linux-arch, linux-doc, linux-mm, lkml
From: Deepak Gupta <hidden>
Date: 2023-03-17 17:06:08
Also in:
linux-arch, linux-doc, linux-mm, lkml
On Mon, Feb 27, 2023 at 2:31 PM Rick Edgecombe [off-list ref] wrote:
diff --git a/mm/gup.c b/mm/gup.c index eab18ba045db..e7c7bcc0e268 100644 --- a/mm/gup.c +++ b/mm/gup.c@@ -978,7 +978,7 @@ static int check_vma_flags(struct vm_area_struct *vma, unsigned long gup_flags) return -EFAULT; if (write) { - if (!(vm_flags & VM_WRITE)) { + if (!(vm_flags & VM_WRITE) || (vm_flags & VM_SHADOW_STACK)) {
I think I missed this in the review. `VM_SHADOW_STACK` is an x86 specific vmaflag to represent a shadow stack VMA. Since this is arch agnostic code. Can we instead have `is_arch_shadow_stack_vma` which consumes vma flags and returns true. This allows different architectures to choose whatever encoding of the vma flag to represent a shadow stack.
if (!(gup_flags & FOLL_FORCE))
return -EFAULT;
/* hugetlb does not support FOLL_FORCE|FOLL_WRITE. */
--
2.17.1