Re: [PATCH for 4.14-stable] s390/mm: validate VMA in PGSTE manipulation functions

From: Greg KH
Date: Sun Nov 28 2021 - 06:56:57 EST


On Fri, Nov 26, 2021 at 06:15:36PM +0100, David Hildenbrand wrote:
> commit fe3d10024073f06f04c74b9674bd71ccc1d787cf 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"). gfn_to_hva() will only translate using
> KVM memory regions, but won't validate the VMA.
>
> Further, we should not allocate page tables outside of VMA boundaries: if
> evil user space decides to map hugetlbfs to these ranges, bad things will
> happen because we suddenly have PTE or PMD page tables where we
> shouldn't have them.
>
> Similarly, we have to check if we suddenly find a hugetlbfs VMA, before
> calling get_locked_pte().
>
> Fixes: 2d42f9477320 ("s390/kvm: Add PGSTE manipulation functions")
> Signed-off-by: David Hildenbrand <david@xxxxxxxxxx>
> Reviewed-by: Claudio Imbrenda <imbrenda@xxxxxxxxxxxxx>
> Acked-by: Heiko Carstens <hca@xxxxxxxxxxxxx>
> Link: https://lore.kernel.org/r/20210909162248.14969-4-david@xxxxxxxxxx
> Signed-off-by: Christian Borntraeger <borntraeger@xxxxxxxxxx>
> Signed-off-by: David Hildenbrand <david@xxxxxxxxxx>
> ---
> arch/s390/mm/pgtable.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)

What about for 5.10-stable and 5.4-stable and 4.19-stable? Will this
commit work there as well?

thanks,

greg k-h