Received: by 10.223.185.116 with SMTP id b49csp5465838wrg; Wed, 7 Mar 2018 12:14:08 -0800 (PST) X-Google-Smtp-Source: AG47ELsWqmCZPEml0KlXpWDwL+IW2Vhs3KQ4OtUIpvvx33quW/BsnEBbtmdfFTHaHcyyD1GKPDYl X-Received: by 10.99.99.66 with SMTP id x63mr19400459pgb.421.1520453648576; Wed, 07 Mar 2018 12:14:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520453648; cv=none; d=google.com; s=arc-20160816; b=O8rtfFpqGZoHWOOYc0uSW0GEFcD1A7Y0il6IQGy8F6t8hMjfPtPixdwZWbLV0SBtS4 nuK2W9twlNhbp2rIQK+Jzr15xrSEq9+Hn+Av43IARqCpuTbOr9O4kd5JboLD6hhDBYFp llsMylxD8byXu9qP3TBjwHIzm5fNvQJFw9qDw6jSpaI6Lt+B846Ab+/q3AypbSmAwVL+ HJqMuGVHzqWDcQyULLWioucGx9PW3JVCfGLFRG+kFZ0jcB+B03r1CPb+E3rnx3wvPkK/ TRncf5dR18zvJI+/ICm7/CI4soigB6SPLD0SWWIxrw3x5LrUKn9oCBDIjxut7THaqm/w GfwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=NklUq1Q2I2JMO9kkFDHL/UBHmzHXZsP4nwhxeHQXvhg=; b=YnSRBNqlc6FipIv0JgS0LgTArx3N8q0YMwQhzl5S3SYj7XrESkeYEkAjEtr7P663+0 ISppJkGnCQSp11cDmckcQQdsVPcKuge0tYxE2MQOe2ScApCrHbtVKmfc4lSw3/tiOnFU gr3UH7lKCvqGD6XCLvzYMkp3dxtXGuM0umYRFlryHRkjCZ1QM3QGYmE5pSlhYao4kJeP dWjifFDMOcbTAPNvK2hRJnUR5qjKFpumZhu0/YkgoNCAVy0YeyiW97OhhOz23353QPFq xt643GmsNQN2KWAKmxd0zAM6NOVCGImWkdjOF2AVUrCtBHeFPIbiRYfC4Dt66291stpv UMkw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bd7-v6si660612plb.474.2018.03.07.12.13.54; Wed, 07 Mar 2018 12:14:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965306AbeCGUNF (ORCPT + 99 others); Wed, 7 Mar 2018 15:13:05 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:44082 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965255AbeCGTpL (ORCPT ); Wed, 7 Mar 2018 14:45:11 -0500 Received: from localhost (unknown [185.236.200.248]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 9B661F1E; Wed, 7 Mar 2018 19:45:10 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alex Williamson , Michal Hocko , kvm@vger.kernel.org, Haozhong Zhang , Christoph Hellwig , Dan Williams Subject: [PATCH 4.14 027/110] vfio: disable filesystem-dax page pinning Date: Wed, 7 Mar 2018 11:38:10 -0800 Message-Id: <20180307191043.187618642@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180307191039.748351103@linuxfoundation.org> References: <20180307191039.748351103@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dan Williams commit 94db151dc89262bfa82922c44e8320cea2334667 upstream. Filesystem-DAX is incompatible with 'longterm' page pinning. Without page cache indirection a DAX mapping maps filesystem blocks directly. This means that the filesystem must not modify a file's block map while any page in a mapping is pinned. In order to prevent the situation of userspace holding of filesystem operations indefinitely, disallow 'longterm' Filesystem-DAX mappings. RDMA has the same conflict and the plan there is to add a 'with lease' mechanism to allow the kernel to notify userspace that the mapping is being torn down for block-map maintenance. Perhaps something similar can be put in place for vfio. Note that xfs and ext4 still report: "DAX enabled. Warning: EXPERIMENTAL, use at your own risk" ...at mount time, and resolving the dax-dma-vs-truncate problem is one of the last hurdles to remove that designation. Acked-by: Alex Williamson Cc: Michal Hocko Cc: kvm@vger.kernel.org Cc: Reported-by: Haozhong Zhang Tested-by: Haozhong Zhang Fixes: d475c6346a38 ("dax,ext2: replace XIP read and write with DAX I/O") Reviewed-by: Christoph Hellwig Signed-off-by: Dan Williams Signed-off-by: Greg Kroah-Hartman --- drivers/vfio/vfio_iommu_type1.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -338,11 +338,12 @@ static int vaddr_get_pfn(struct mm_struc { struct page *page[1]; struct vm_area_struct *vma; + struct vm_area_struct *vmas[1]; int ret; if (mm == current->mm) { - ret = get_user_pages_fast(vaddr, 1, !!(prot & IOMMU_WRITE), - page); + ret = get_user_pages_longterm(vaddr, 1, !!(prot & IOMMU_WRITE), + page, vmas); } else { unsigned int flags = 0; @@ -351,7 +352,18 @@ static int vaddr_get_pfn(struct mm_struc down_read(&mm->mmap_sem); ret = get_user_pages_remote(NULL, mm, vaddr, 1, flags, page, - NULL, NULL); + vmas, NULL); + /* + * The lifetime of a vaddr_get_pfn() page pin is + * userspace-controlled. In the fs-dax case this could + * lead to indefinite stalls in filesystem operations. + * Disallow attempts to pin fs-dax pages via this + * interface. + */ + if (ret > 0 && vma_is_fsdax(vmas[0])) { + ret = -EOPNOTSUPP; + put_page(page[0]); + } up_read(&mm->mmap_sem); }