s390/pci_mmio: fully validate the VMA before calling follow_pte()
authorDavid Hildenbrand <david@redhat.com>
Thu, 9 Sep 2021 14:59:42 +0000 (16:59 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 26 Sep 2021 12:08:55 +0000 (14:08 +0200)
commit79286ea830b3922b38bcefbd150b2010f91a55ce
tree7ef7be05026d71a89636848bfe302820788a39c8
parent74d54e5ceba3f50b9b695e4740172d876327815a
s390/pci_mmio: fully validate the VMA before calling follow_pte()

commit a8b92b8c1eac8d655a97b1e90f4d83c25d9b9a18 upstream.

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 dd2283f2605e ("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: dd2283f2605e ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/s390/pci/pci_mmio.c