Skip to content

Commit a8b92b8

Browse files
davidhildenbrandVasily Gorbik
authored andcommitted
s390/pci_mmio: fully validate the VMA before calling follow_pte()
We should not walk/touch page tables outside of VMA boundaries when holding only the mmap sem in read mode. Evil user space can modify the VMA layout just before this function runs and e.g., trigger races with page table removal code since commit dd2283f ("mm: mmap: zap pages with read mmap_sem in munmap"). find_vma() does not check if the address is >= the VMA start address; use vma_lookup() instead. Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com> Reviewed-by: Liam R. Howlett <Liam.Howlett@oracle.com> Fixes: dd2283f ("mm: mmap: zap pages with read mmap_sem in munmap") Signed-off-by: David Hildenbrand <david@redhat.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
1 parent 6880fa6 commit a8b92b8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/s390/pci/pci_mmio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ SYSCALL_DEFINE3(s390_pci_mmio_write, unsigned long, mmio_addr,
159159

160160
mmap_read_lock(current->mm);
161161
ret = -EINVAL;
162-
vma = find_vma(current->mm, mmio_addr);
162+
vma = vma_lookup(current->mm, mmio_addr);
163163
if (!vma)
164164
goto out_unlock_mmap;
165165
if (!(vma->vm_flags & (VM_IO | VM_PFNMAP)))
@@ -298,7 +298,7 @@ SYSCALL_DEFINE3(s390_pci_mmio_read, unsigned long, mmio_addr,
298298

299299
mmap_read_lock(current->mm);
300300
ret = -EINVAL;
301-
vma = find_vma(current->mm, mmio_addr);
301+
vma = vma_lookup(current->mm, mmio_addr);
302302
if (!vma)
303303
goto out_unlock_mmap;
304304
if (!(vma->vm_flags & (VM_IO | VM_PFNMAP)))

0 commit comments

Comments
 (0)