diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 8e791a3db6b6804987ae587feff95c79ac940480..8e07342b52c0406982e3cdd2e747c4f18a9efe01 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1262,6 +1262,9 @@ int do_huge_pmd_numa_page(struct mm_struct *mm, struct vm_area_struct *vma, bool migrated = false; int flags = 0; + /* A PROT_NONE fault should not end up here */ + BUG_ON(!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE))); + ptl = pmd_lock(mm, pmdp); if (unlikely(!pmd_same(pmd, *pmdp))) goto out_unlock; diff --git a/mm/memory.c b/mm/memory.c index bf244f56b05ac9ef78404ac926438a52cd844cbd..f7886ab036e715c095d660d6ed95698a412bdca8 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3013,6 +3013,9 @@ static int do_numa_page(struct mm_struct *mm, struct vm_area_struct *vma, bool migrated = false; int flags = 0; + /* A PROT_NONE fault should not end up here */ + BUG_ON(!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE))); + /* * The "pte" at this point cannot be used safely without * validation through pte_unmap_same(). It's of NUMA type but