Skip to contentSkip to conversation

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

PATCH Janosch Frank 1 participant 1 message Aug 16, 2018 1 message not in the archive s390

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --udVIMxf7gRmhoXNSRF4fEytG5mvg5rbwj
Content-Type: multipart/mixed; boundary="fhRVzzD67xPUFIeAndgqd93KpxM8l2IdJ";
protected-headers="v1"
From: Janosch Frank <[email protected]>
To: David Hildenbrand <[email protected]>, [email protected]
Cc: [email protected], [email protected]
Message-ID: <[email protected]>
Subject: Re: [PATCH] s390/mm: Check for valid vma before zapping in
gmap_discard
References: <[email protected]>
<[email protected]>
In-Reply-To: <[email protected]>

--fhRVzzD67xPUFIeAndgqd93KpxM8l2IdJ
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: quoted-printable

Quoted 13 lines · David Hildenbrand
Quoted 12 lines · Janosch Frank

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.

---
 arch/s390/mm/gmap.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Quoted 5 lines

arch/s390/mm/gmap.c void gmap_discard(struct gmap *gmap, unsigned lo=

Quoted 5 lines
arch/s390/mm/gmap.c +0 -0
index bb44990c8212..911c7ded35f1 100644
@@ -708,11 +708,13 @@ void gmap_discard(struct gmap *gmap, unsigned lo=

ng from, unsigned long to)

Quoted 16 lines
Quoted 5 lines
arch/s390/mm/gmap.c +1 -0
 		vmaddr |=3D gaddr & ~PMD_MASK;
 		/* Find vma in the parent mm */
 		vma =3D find_vma(gmap->mm, vmaddr);
+		if (!vma)

arch/s390/mm/gmap.c void gmap_discard(struct gmap *gmap, unsigned lo= · line 720

Quoted 10 lines
arch/s390/mm/gmap.c +2 -1
+			continue;
 		/*
 		 * We do not discard pages that are backed by
 		 * hugetlbfs, so we don't have to refault them.
 		 */
-		if (vma && is_vm_hugetlb_page(vma))
+		if (is_vm_hugetlb_page(vma))
 			continue;
 		size =3D min(to - gaddr, PMD_SIZE - (gaddr & ~PMD_MASK));
 		zap_page_range(vma, vmaddr, size);

=20

Quoted 1 line

That was fast.
Thanks

--fhRVzzD67xPUFIeAndgqd93KpxM8l2IdJ--

--udVIMxf7gRmhoXNSRF4fEytG5mvg5rbwj
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBCAAGBQJbdTcOAAoJEBcO/8Q8ZEV5P7MQALe1IY62JOfDcL4o+wogoFrW BMj88sjltq+H4x2my3S7NIbww12twjWA+HvXY1fThVbnZBdYyjlDzPwMSwi+621P 0ICmqc3UAVu95J6YZOIyGQbiZZ7tTwY8uJZ6hS4nMsEf+qXZ0LejOfJ4lmYoaB+b tiUj9szVqhW5RVv3lrUncDMYWZWKmvSfEd2agZ46q6yRMDh9nFKr4nSfqIJrwjx3 ULdr5YKwhyOAydl7SGHy1aQCs0/EgYnR4bYiwegewWBSim2va7fvA+LoLGNki6kL t56IT0N+qDV05OnzAmx86tRfT8qHugcdwPxIj0axsfjk/jLRG3m6x8AQ8N1JpyZo VVnObnaxIbQV+5TFKjaPXOCpyDZLfvTf4VmE01JC33P5hwOiEAROj1dBmHeWyIwo KJX3MjbfbT8zDG1RROzO1Uxub56eSxUfKdANI1U8e1oN7MhNV3CmWPi5xIuK8634 CUyEvOQa6BTBF+RWr8TsYekooLO6erhM2A4n1oX25viG09OzigsZ6Ikos11kORWN HyY/CTUvmxVB275mMaLkLTUSfRHPhjfH7rIIumnL0hKq7dW1vabAr0Gy4qIZ2/Gy pd9Mz0h0wveJCdlGjIZZ9O2CWFOHWSXGzpUHlZ45OE5WDqq9ur+h8jVfHkkjx5v9 6YAGOPzUKfk1KPv7Vuzh
=brVg
-----END PGP SIGNATURE-----

--udVIMxf7gRmhoXNSRF4fEytG5mvg5rbwj--