Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp845796pxb; Tue, 14 Sep 2021 09:56:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRD/amL+C5xIdMWO3o8FdL5RAbZIKB6cleOZO4bv97D1WuQmX7w7N2OBWcEPIkGrPkstcw X-Received: by 2002:a05:6602:218d:: with SMTP id b13mr14464618iob.143.1631638597762; Tue, 14 Sep 2021 09:56:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631638597; cv=none; d=google.com; s=arc-20160816; b=iyM3IDszJzflKjpbKZqLWkE5yNj94FyE9mMSpes+rb0xGxBucJ3Mv/9BdfNLudGzpT BlnM8MyB3gaMaG6o7TQlDBLRHEF8AOy0GvyCJKHA2X7zOZcZ/BLJ7JegWkyc5/AOu731 V4g9sCbhvTfen01sZ53krSRmOd2ZD1LAqRmk3TfwJsYZsJqdQ1Z809X+HEojC2gA7Z6B arqCibymbgolZe/9YI2eUxVk0wukRAGNOBrOQU4CseTl6zrofKmG3/7rlDinVGFNpitm cVmXEmnSCL1QDv9IakSXHgMQJv5G8Lpa1BVLqIXy6WjxpCRA5Nxpxn2spn+P+ApkcMaS RDcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=Qy4X9/oxBqi8dDd9OpSU+FwGexrK2UVH0Cx+696cXRs=; b=AAFGYLMmHdVURjRJdZ9KSgCqJzXC7to4ED7JcZ2C/eO4OSJJvnuzVwIj0/QFoSraBO QnfLKBL1Gpk5hBpXYUpm9Lm7hELpJDe6rAq4pHWpGADsFQAKgtu04xp+3rEWvg5OGkKn jrE6cuQfvNBjr/uqWOAV5ieuIt4N0LWunRseGLBwMo0ICrG1xH+yh6hi4Wb+FCrAE/Qx UlJfDKQYQVmi82rd2esr4NHOazpnaq9eVIXNTKl77nkP5IO4pLIrZYeU5ZMaAm3zxHWj Xit1ouA/AwQPttnahupV8awGaKywa6ZfNJQaAgZYNoeWO6YEVttTpdFhMBqvSu83euy5 vKwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=MA8QjBHw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g6si3127758jaq.62.2021.09.14.09.56.25; Tue, 14 Sep 2021 09:56:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=MA8QjBHw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230282AbhINQ4F (ORCPT + 99 others); Tue, 14 Sep 2021 12:56:05 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:7980 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231363AbhINQ4D (ORCPT ); Tue, 14 Sep 2021 12:56:03 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.0.43) with SMTP id 18EFpo7G029541; Tue, 14 Sep 2021 12:54:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=date : from : to : cc : subject : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=pp1; bh=Qy4X9/oxBqi8dDd9OpSU+FwGexrK2UVH0Cx+696cXRs=; b=MA8QjBHw5XGtOmak3ByHmKiE6nLHvfV4vxc9CTBwKy9XbFeil7MQ8hX4VCnzSeptxk4h hxoA6/SYZSCeRAFroQJ1Urm6NKb0wr/UDiU1aWjhQn/xd/NaT2AEd2EOF7pbfjoUM4Pi +qkSLiYZd86lG6OmZzGI7xe8w6WDSEtO4q9Six3slR2IjdjUKSQOFYxFQGF2DUa8Ck5j ZXGkCfFMziW70zfBmk76zO/bJ9xdzX1BKJpLMkL6SpoknGasjcf813ntLuP+j7aSMdKk Q3BUCC5/3jrFXOLOxZQdPeM4HxwkTIWKX4F9vLe7SyEiRM9BTNsTovOanghrJY0b3sHh wg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3b2s7xb5ps-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Sep 2021 12:54:44 -0400 Received: from m0098421.ppops.net (m0098421.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 18EGr80I001161; Tue, 14 Sep 2021 12:54:44 -0400 Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com with ESMTP id 3b2s7xb5p4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Sep 2021 12:54:44 -0400 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 18EGqDZZ018914; Tue, 14 Sep 2021 16:54:42 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma02fra.de.ibm.com with ESMTP id 3b0m39d9qp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Sep 2021 16:54:42 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 18EGo6TG52232492 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 14 Sep 2021 16:50:06 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2641811C05E; Tue, 14 Sep 2021 16:54:38 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 92E9711C052; Tue, 14 Sep 2021 16:54:37 +0000 (GMT) Received: from p-imbrenda (unknown [9.145.8.12]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 14 Sep 2021 16:54:37 +0000 (GMT) Date: Tue, 14 Sep 2021 18:54:33 +0200 From: Claudio Imbrenda To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, linux-mm@kvack.org, Christian Borntraeger , Janosch Frank , Cornelia Huck , Heiko Carstens , Vasily Gorbik , Niklas Schnelle , Gerald Schaefer , Ulrich Weigand Subject: Re: [PATCH resend RFC 6/9] s390/pci_mmio: fully validate the VMA before calling follow_pte() Message-ID: <20210914185433.41f0a0b9@p-imbrenda> In-Reply-To: <20210909162248.14969-7-david@redhat.com> References: <20210909162248.14969-1-david@redhat.com> <20210909162248.14969-7-david@redhat.com> Organization: IBM X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: b5CqA5O8AQhIJ8v0xe0ZWHEx_u2mGu8j X-Proofpoint-ORIG-GUID: VFoUS8JAy4Q4tgXxfmyp6ep_atmJX52K X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.687,Hydra:6.0.235,FMLib:17.0.607.475 definitions=2020-10-13_15,2020-10-13_02,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 spamscore=0 suspectscore=0 malwarescore=0 priorityscore=1501 clxscore=1015 mlxscore=0 impostorscore=0 phishscore=0 lowpriorityscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109030001 definitions=main-2109140056 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 9 Sep 2021 18:22:45 +0200 David Hildenbrand wrote: > 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"). > > find_vma() does not check if the address is >= the VMA start address; > use vma_lookup() instead. > > Fixes: dd2283f2605e ("mm: mmap: zap pages with read mmap_sem in munmap") > Signed-off-by: David Hildenbrand Reviewed-by: Claudio Imbrenda > --- > arch/s390/pci/pci_mmio.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/s390/pci/pci_mmio.c b/arch/s390/pci/pci_mmio.c > index ae683aa623ac..c5b35ea129cf 100644 > --- a/arch/s390/pci/pci_mmio.c > +++ b/arch/s390/pci/pci_mmio.c > @@ -159,7 +159,7 @@ SYSCALL_DEFINE3(s390_pci_mmio_write, unsigned > long, mmio_addr, > mmap_read_lock(current->mm); > ret = -EINVAL; > - vma = find_vma(current->mm, mmio_addr); > + vma = vma_lookup(current->mm, mmio_addr); > if (!vma) > goto out_unlock_mmap; > if (!(vma->vm_flags & (VM_IO | VM_PFNMAP))) > @@ -298,7 +298,7 @@ SYSCALL_DEFINE3(s390_pci_mmio_read, unsigned > long, mmio_addr, > mmap_read_lock(current->mm); > ret = -EINVAL; > - vma = find_vma(current->mm, mmio_addr); > + vma = vma_lookup(current->mm, mmio_addr); > if (!vma) > goto out_unlock_mmap; > if (!(vma->vm_flags & (VM_IO | VM_PFNMAP)))