Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp914782pxu; Wed, 2 Dec 2020 06:38:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJxbG+pOn9EXXWKylAwUG135ZvGqVHPrgrA/V+fC0cI6aP3X/7pbWqysiZ21Izarm4F9ykRr X-Received: by 2002:a17:906:c289:: with SMTP id r9mr45414ejz.311.1606919918796; Wed, 02 Dec 2020 06:38:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606919918; cv=none; d=google.com; s=arc-20160816; b=iHktPg0A+ZoW1beA1XFJa7dKRyQWkUxtsko9/hFulpJY3hAHymZN2Rv2gb7vkqvB+c XhyQZWOiQp/TUek6nAwhLXYAKgfaMsJ3hyH5Wh5869BEjIptwaFLy/RnMOBEO0S9yHqY C0lKpZsmMBZsg8SaSiYA+9B+2hjHUCD3SJqSFnQTe2ozH2KPOLh0g2bUbXCnlO1nMlY5 Z6+2pg6bMySx1PcxIZjOMzlF+rHAi5c+Ns0/y/XcpSgkNyb5x2MOMa1hOvwy+bU1+gyf 6gTkBYGjAgEHksQT4suNueDQmUYRuuPP0DzmMOyg0gd9bcCnUlb7ZjfoRekgjk6Oln1S y1ZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:in-reply-to:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=0EkevmCLQ1GX33E9KXRD3p8BSpTHh3E7pEzchj2FWow=; b=dD0anycsImIOVncBURwVmTrpN82bujGL5U1zyqx3COp/s43e7ZcLonXs8OqtEOiE3T bFymuT4IDpUnEfJE59Yo8451IECMWixotPSjS6FhrLD0muzTUE59aMM9jCZgaHbuIEzr y7NSKlNPuxpnO7fqksKzE4mi7Mhx1bcrvsFJM6baB6YLu92PhL6ITbqOEyQ0day15TDs Xr9vLh1163AsDmJy1KnOPRmggeovfE1oIDdrZN2EaS8Vdx0oG3bZ/vaNp/izvJB0Nre+ erfbb7ah694g4bSdqDqIFnmEgVmXlNrDCRHSmlT2AoZLLwmHsaht2w3RzhaEBlNe+cIw OlrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="PcH/w7Q5"; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o23si48944edt.543.2020.12.02.06.38.14; Wed, 02 Dec 2020 06:38:38 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b="PcH/w7Q5"; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728156AbgLBOfg (ORCPT + 99 others); Wed, 2 Dec 2020 09:35:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:50419 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726071AbgLBOff (ORCPT ); Wed, 2 Dec 2020 09:35:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606919648; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0EkevmCLQ1GX33E9KXRD3p8BSpTHh3E7pEzchj2FWow=; b=PcH/w7Q5z45LiEl6kAK/on4/tFn8m4LcHsBywo/9C3rj7wqRl9rgQoxRtroWX0yp7monEr nftUt1hrEE2fDEXsQ9/GrUq00nWE08qGfWdG6JD6AQPbxr5wBkIlAoVS3Gas+PY0Y5Hbv9 bhxpk7QhJssq3bxddVPsJqZTejV8BpA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-82-OXLcuBxbOca-YDdOQG16zw-1; Wed, 02 Dec 2020 09:34:06 -0500 X-MC-Unique: OXLcuBxbOca-YDdOQG16zw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 95C91100E324; Wed, 2 Dec 2020 14:34:05 +0000 (UTC) Received: from localhost (ovpn-114-255.ams2.redhat.com [10.36.114.255]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B72D5C1D0; Wed, 2 Dec 2020 14:33:57 +0000 (UTC) Date: Wed, 2 Dec 2020 14:33:56 +0000 From: Stefan Hajnoczi To: Peter Xu Cc: Justin He , Alex Williamson , Cornelia Huck , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] vfio iommu type1: Bypass the vma permission check in vfio_pin_pages_remote() Message-ID: <20201202143356.GK655829@stefanha-x1.localdomain> References: <20201119142737.17574-1-justin.he@arm.com> <20201124181228.GA276043@xz-x1> <20201125155711.GA6489@xz-x1> MIME-Version: 1.0 In-Reply-To: <20201125155711.GA6489@xz-x1> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=stefanha@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="qDymnuGqqhW10CwH" Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --qDymnuGqqhW10CwH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Nov 25, 2020 at 10:57:11AM -0500, Peter Xu wrote: > On Wed, Nov 25, 2020 at 01:05:25AM +0000, Justin He wrote: > > > I'd appreciate if you could explain why vfio needs to dma map some > > > PROT_NONE > >=20 > > Virtiofs will map a PROT_NONE cache window region firstly, then remap t= he sub > > region of that cache window with read or write permission. I guess this= might > > be an security concern. Just CC virtiofs expert Stefan to answer it mor= e accurately. >=20 > Yep. Since my previous sentence was cut off, I'll rephrase: I was thinki= ng > whether qemu can do vfio maps only until it remaps the PROT_NONE regions = into > PROT_READ|PROT_WRITE ones, rather than trying to map dma pages upon PROT_= NONE. Userspace processes sometimes use PROT_NONE to reserve virtual address space. That way future mmap(NULL, ...) calls will not accidentally allocate an address from the reserved range. virtio-fs needs to do this because the DAX window mappings change at runtime. Initially the entire DAX window is just reserved using PROT_NONE. When it's time to mmap a portion of a file into the DAX window an mmap(fixed_addr, ...) call will be made. Stefan --qDymnuGqqhW10CwH Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEhpWov9P5fNqsNXdanKSrs4Grc8gFAl/HpdQACgkQnKSrs4Gr c8gPrggAonKj8u861YBXdwmd9ewmkx/VVa0WqmIb9BHstu+ZJU4vEPWSCLs6Ztk3 JlIeWhuwfvHWLRcEL7iki0ON0jgsV4076axu8aFvl0NsKWQk2TTIA3VwUiWh76Li Qy18X6LEEaR6UAJVgp1mQTG8oQzYQwvirdJSwWUSydq0SmhXPNHFeuRGxmmtcTIR 9JzPk8VIqzddHqEnAHcFUTCE40830cm4oaSq1nesTpqwkuv9nx0tBmE4xj26TONM pTEHitIJKZIgxh6ZeDDAizwiRZp4l6DMuEb0vxiNsrBaddhe5sIoa7DwGgiXn0Ps ImXZKCwuxOieIb+HAIyjmwe3fIjctQ== =P7/h -----END PGP SIGNATURE----- --qDymnuGqqhW10CwH--