Skip to contentSkip to conversation

s390/mm: Check for valid vma before zapping in gmap_discard

PATCH New Janosch Frank 1 participant 1 message Nov 8, 2018 Stable branch

lore
Share & tools
lore
#0 lore raw

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)")
---
 arch/s390/mm/pgtable.c | 2 ++
 1 file changed, 2 insertions(+)
arch/s390/mm/pgtable.c +2 -0
index 05ae254..1866b6a 100644
@@ -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