s390/mm: Check for valid vma before zapping in gmap_discard
PATCH 1/1 s390/mm: Check for valid vma before zapping in gmap_discard
From: Janosch Frank <[email protected]>
Userspace could have munmapped the area before doing unmapping from the gmap. This would leave us with a valid vmaddr, but an invalid vma from which we would try to zap memory. Let's check before using the vma.
Function was moved with 1e133ab296f3 in v4.6.
Is 1843abd upstream.
Fixes 388186b ("kvm: Handle diagnose 0x10 (release pages)")
Signed-off-by Janosch Frank <[email protected]>
Reviewed-by David Hildenbrand <[email protected]>
Reported-by Dan Carpenter <[email protected]>
CC <[email protected]> # 4.4
--- arch/s390/mm/pgtable.c | 2 ++ 1 file changed, 2 insertions(+)
arch/s390/mm/pgtable.c +2 -0
@@ -637,6 +637,8 @@ void gmap_discard(struct gmap *gmap, unsigned long from, unsigned long to) vmaddr |= gaddr & ~PMD_MASK ;/* Find vma in the parent mm */ vma =find_vma (gmap->mm, vmaddr); +if (!vma) +continue ; size =min (to - gaddr,PMD_SIZE - (gaddr & ~PMD_MASK ));zap_page_range (vma, vmaddr, size,NULL ); }
Signature · 1 line
2.7.4