Skip to contentSkip to conversation

iommu/amd: Fix BUG when faulting a PROT_NONE VMA

PATCH RESEND Applied Jay Cornwall 2 participants 4 messages Oct 13, 2015 – Oct 15, 2015 3 messages not in the archive IOMMU

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 iommu/amd: Fix BUG when faulting a PROT_NONE VMA

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)));

---
 drivers/iommu/amd_iommu_v2.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/iommu/amd_iommu_v2.c +7 -0
index 1131664..d21d4ed 100644
@@ -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 */
Signature · 1 line
1.9.1

A message that is not in the archive (sent off-list or not yet received): 1444729963-13815-1-git-send-email-jay-gJmSnxjMpeIFV7jr3Ov9Ew@public.gmane.org

#2 lore raw

Hi Jay,

Quoted 10 lines · Jay Cornwall

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)));

Thanks for the fix! Next time please Cc me directly on patches for AMD IOMMU code, so I see your patches earlier.

Also this looks relevant for stable, can you find out which stable kernels need this fix too?

Thanks,

Joerg

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw
Quoted 15 lines · Joerg Roedel

Hi Jay,

Quoted 11 lines · Jay Cornwall

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)));

Quoted 5 lines

Thanks for the fix! Next time please Cc me directly on patches for AMD IOMMU code, so I see your patches earlier.

Also this looks relevant for stable, can you find out which stable kernels need this fix too?

Sure.

Cc <[email protected]> # v4.1+
Signature · 1 line
Jay Cornwall

A message that is not in the archive (sent off-list or not yet received): 0528b4ee6c9af3fa326880eb18cf13b8-gJmSnxjMpeIFV7jr3Ov9Ew@public.gmane.org

Applied
#6 lore raw
Quoted 20 lines · Jay Cornwall
Quoted 19 lines · Joerg Roedel

Hi Jay,

Quoted 4 lines · Jay Cornwall

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.

Quoted 8 lines

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)));

Thanks for the fix! Next time please Cc me directly on patches for AMD IOMMU code, so I see your patches earlier.

Quoted 6 lines
Quoted 2 lines

Also this looks relevant for stable, can you find out which stable kernels need this fix too?

Sure.

Cc <[email protected]> # v4.1+

Applied, thanks.