public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 4.4] s390/mm: Check for valid vma before zapping in gmap_discard
@ 2018-11-08  8:37 Janosch Frank
  0 siblings, 0 replies; only message in thread
From: Janosch Frank @ 2018-11-08  8:37 UTC (permalink / raw)
  To: stable; +Cc: borntraeger

From: Janosch Frank <frankja@de.ibm.com>

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 <frankja@de.ibm.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
CC: <stable@vger.kernel.org> # 4.4
---
 arch/s390/mm/pgtable.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/s390/mm/pgtable.c b/arch/s390/mm/pgtable.c
index 05ae254..1866b6a 100644
--- a/arch/s390/mm/pgtable.c
+++ b/arch/s390/mm/pgtable.c
@@ -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);
 	}
-- 
2.7.4

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2018-11-08 18:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-08  8:37 [PATCH 4.4] s390/mm: Check for valid vma before zapping in gmap_discard Janosch Frank

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox