* [PATCH 5.10 STABLE] s390/pci_mmio: fully validate the VMA before calling follow_pte()
[not found] <1632128112176198@kroah.com>
@ 2021-09-20 13:17 ` David Hildenbrand
2021-09-23 8:03 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: David Hildenbrand @ 2021-09-20 13:17 UTC (permalink / raw)
To: stable
Cc: linux-kernel, gregkh, David Hildenbrand, Niklas Schnelle,
Liam R . Howlett
commit a8b92b8c1eac8d655a97b1e90f4d83c25d9b9a18 upstream.
Note: We don't have vma_lookup() in the 5.4-stable tree, so perform the VMA
check manually.
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: David Hildenbrand <david@redhat.com>
---
arch/s390/pci/pci_mmio.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/s390/pci/pci_mmio.c b/arch/s390/pci/pci_mmio.c
index 401cf670a243..37b1bbd1a27c 100644
--- a/arch/s390/pci/pci_mmio.c
+++ b/arch/s390/pci/pci_mmio.c
@@ -128,7 +128,7 @@ static long get_pfn(unsigned long user_addr, unsigned long access,
mmap_read_lock(current->mm);
ret = -EINVAL;
vma = find_vma(current->mm, user_addr);
- if (!vma)
+ if (!vma || user_addr < vma->vm_start)
goto out;
ret = -EACCES;
if (!(vma->vm_flags & access))
--
2.31.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 5.10 STABLE] s390/pci_mmio: fully validate the VMA before calling follow_pte()
2021-09-20 13:17 ` [PATCH 5.10 STABLE] s390/pci_mmio: fully validate the VMA before calling follow_pte() David Hildenbrand
@ 2021-09-23 8:03 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2021-09-23 8:03 UTC (permalink / raw)
To: David Hildenbrand; +Cc: stable, linux-kernel, Niklas Schnelle, Liam R . Howlett
On Mon, Sep 20, 2021 at 03:17:49PM +0200, David Hildenbrand wrote:
> commit a8b92b8c1eac8d655a97b1e90f4d83c25d9b9a18 upstream.
>
> Note: We don't have vma_lookup() in the 5.4-stable tree, so perform the VMA
> check manually.
Both backports now queued up, thanks.
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-09-23 8:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <1632128112176198@kroah.com>
2021-09-20 13:17 ` [PATCH 5.10 STABLE] s390/pci_mmio: fully validate the VMA before calling follow_pte() David Hildenbrand
2021-09-23 8:03 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome