All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RESEND] iommu/amd: Fix BUG when faulting a PROT_NONE VMA
@ 2015-10-13  9:52 Jay Cornwall
       [not found] ` <1444729963-13815-1-git-send-email-jay-gJmSnxjMpeIFV7jr3Ov9Ew@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Jay Cornwall @ 2015-10-13  9:52 UTC (permalink / raw)
  To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA

handle_mm_fault indirectly triggers a BUG in do_numa_page when given
a VMA without read/write/execute access. Check this condition in do_fault.

do_fault -> handle_mm_fault -> handle_pte_fault -> do_numa_page

  mm/memory.c
  3147  static int do_numa_page(struct mm_struct *mm, struct vm_area_st...
  ....
  3159  /* A PROT_NONE fault should not end up here */
  3160  BUG_ON(!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE)));

Signed-off-by: Jay Cornwall <jay-gJmSnxjMpeIFV7jr3Ov9Ew@public.gmane.org>
---
 drivers/iommu/amd_iommu_v2.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/iommu/amd_iommu_v2.c b/drivers/iommu/amd_iommu_v2.c
index 1131664..d21d4ed 100644
--- a/drivers/iommu/amd_iommu_v2.c
+++ b/drivers/iommu/amd_iommu_v2.c
@@ -516,6 +516,13 @@ static void do_fault(struct work_struct *work)
 		goto out;
 	}
 
+	if (!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE))) {
+		/* handle_mm_fault would BUG_ON() */
+		up_read(&mm->mmap_sem);
+		handle_fault_error(fault);
+		goto out;
+	}
+
 	ret = handle_mm_fault(mm, vma, address, write);
 	if (ret & VM_FAULT_ERROR) {
 		/* failed to service fault */
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-10-15 14:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-13  9:52 [PATCH RESEND] iommu/amd: Fix BUG when faulting a PROT_NONE VMA Jay Cornwall
     [not found] ` <1444729963-13815-1-git-send-email-jay-gJmSnxjMpeIFV7jr3Ov9Ew@public.gmane.org>
2015-10-14  9:10   ` Joerg Roedel
     [not found]     ` <20151014091015.GJ27420-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2015-10-14 16:56       ` Jay Cornwall
     [not found]         ` <0528b4ee6c9af3fa326880eb18cf13b8-gJmSnxjMpeIFV7jr3Ov9Ew@public.gmane.org>
2015-10-15 14:13           ` Joerg Roedel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.