Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp40244ybl; Tue, 27 Aug 2019 15:25:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqyB47Bpy7K3tB7WuLLvpe7rH+vXn4/g2+nyxRCJlBdcP9MSQhUaY7eiSR8kAuXr8NhRJ+zA X-Received: by 2002:a63:dd17:: with SMTP id t23mr639413pgg.295.1566944722729; Tue, 27 Aug 2019 15:25:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566944722; cv=none; d=google.com; s=arc-20160816; b=R5eLEcdoH/pqSFlKbftMBFCTutVh4G7IIqyMUMGhSijYmjEicW1E7voxEluO9HE5Ls Bw6MJj16vyld0o95YM2niCR/oJvDRnyQMFBQnNk2dbXe5jQyMH8hCTqqpIqRGNmZ5+ya ecpjmap+ElROT8Yxac4gn/xgaRrjN5bQAJRmOET+yzx2jKgi5+q38xPEI2rHXMDK7bQi 8/tGo3pHgW9flmVo//2+TQvWKvGZFy8EuGQfnpuqy3juLD2MW7bGSNQeyzwOlgpeGk5u 6pXgT5p27ILMLKcFs0sAUdDnuiY2VhENYC5XIyBf08Ttl41tpyKhYoU6K2foSPUGDAAw 408w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=O/Eb9Yv9aHdMVq7eZpOlz+xzQGez6PZaf9uMsvKFVSk=; b=TwEZlaon1payUXTOPPNba7/nvW5o5d/3wYYY0a0TgSQ9XHJuwpy09ts8Sw+c9zedQl FrRe0YPp6fQ5xoTIHGgOmO6ozcVci57eVVcPtW/7qgn4OBt4r7ob2pcIdpZfyPeIQMVW zEZIXANnabstvcO7VzqxtxmRzF8j6otiIpYaPpUMzJp5a4xFeiTQv45ClFdzyDW9EOok w+TdyXsyD2vBHGMyxk9nuz5IT99W4g1oCGM5+Ox18X1eR3VnQeDBTIy1baPz9gexYsZ3 /OAxUJMvOpYLRjTNKQ8CAB0287V3PlJB50VNe3kXYCAYGPeMBTesBiv3w+N8RQF6uks+ Zheg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=S5udK1mC; 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 v12si554791pgl.102.2019.08.27.15.25.03; Tue, 27 Aug 2019 15:25:22 -0700 (PDT) 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; dkim=pass header.i=@ziepe.ca header.s=google header.b=S5udK1mC; 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 S1726462AbfH0WWW (ORCPT + 99 others); Tue, 27 Aug 2019 18:22:22 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:41963 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725976AbfH0WWW (ORCPT ); Tue, 27 Aug 2019 18:22:22 -0400 Received: by mail-qt1-f193.google.com with SMTP id i4so725985qtj.8 for ; Tue, 27 Aug 2019 15:22:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=O/Eb9Yv9aHdMVq7eZpOlz+xzQGez6PZaf9uMsvKFVSk=; b=S5udK1mCM17tEnM8qe/Euf0h6hUrQ+FsIrJswR0TUa9fPCRYoUQo2Bj0vFq0Fv5x7W brf7rtaaLWpCWBBcKPEArqo55P7LK9Y+3eaAJqaKFm9q2TqOIryQNcOTxeO43ahRyXMz +78BCiCK8tOS1KfOCv/vOzajMjclnKu+sqNB45ittMbYMfVVgnS3nM2+4LsDNk/3U5wE KGi8UiI7+GqWkinARDlIKI/eUAIOW3lDoAfSJWFqbiG0llZz8rTszgW14HlsyNgX7pzb W7N9EDComqNskKX+zkqao8RVYlPByzJ2Rr93KmNG9Ioy0A2C6bMSUxiivkfsaaJUAjXo HBtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=O/Eb9Yv9aHdMVq7eZpOlz+xzQGez6PZaf9uMsvKFVSk=; b=bX33p6MN4i6BjAmQ2iW84JAjMMivMQG+ZlUHzC98TL1u5+prJH7QJfvwsOTI6x1BJK hVEbt9NqZHy1v9upXSyw0qnfNpXm3gi5U1tGPQbOjcop3C1cB4foz5AjeTW/o6PU9bX7 +tzrP+QEckZPvCDSSi3UAX+I8yJ/609kHaqsunNNKjOoXfyIxlaAd2apG86ixZy0Rkcz HOS4JBwhHB5m86W2JXq9pytuSW5PrknssJ563/4TbtR4wJmCv70fMW721Pb+rHI1BSLN 4x4woEePx37IsTkoqH+CPCUbWiQNjxbRfjc0oacxk1qQbNvX0T+xGDHDWkoYpwVX4skm h0Ew== X-Gm-Message-State: APjAAAXqY9eejp3LSKLgLCWH/RScP4LJFaGFyy8y+4lGq0ybVec2D1I1 WHtyFqVMA6yu+VWd5v66FRHtaw== X-Received: by 2002:ad4:47c3:: with SMTP id p3mr808533qvw.120.1566944540997; Tue, 27 Aug 2019 15:22:20 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-167-216-168.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.167.216.168]) by smtp.gmail.com with ESMTPSA id y25sm408767qkj.35.2019.08.27.15.22.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Aug 2019 15:22:20 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1i2jr1-00080x-Hu; Tue, 27 Aug 2019 19:22:19 -0300 Date: Tue, 27 Aug 2019 19:22:19 -0300 From: Jason Gunthorpe To: Ralph Campbell Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, =?utf-8?B?SsOpcsO0bWU=?= Glisse , Andrew Morton , Christoph Hellwig Subject: Re: [PATCH 2/2] mm/hmm: hmm_range_fault() infinite loop Message-ID: <20190827222219.GA30700@ziepe.ca> References: <20190823221753.2514-1-rcampbell@nvidia.com> <20190823221753.2514-3-rcampbell@nvidia.com> <20190827184157.GA24929@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 27, 2019 at 01:16:13PM -0700, Ralph Campbell wrote: > > On 8/27/19 11:41 AM, Jason Gunthorpe wrote: > > On Fri, Aug 23, 2019 at 03:17:53PM -0700, Ralph Campbell wrote: > > > > > Signed-off-by: Ralph Campbell > > > mm/hmm.c | 3 +++ > > > 1 file changed, 3 insertions(+) > > > > > > diff --git a/mm/hmm.c b/mm/hmm.c > > > index 29371485fe94..4882b83aeccb 100644 > > > +++ b/mm/hmm.c > > > @@ -292,6 +292,9 @@ static int hmm_vma_walk_hole_(unsigned long addr, unsigned long end, > > > hmm_vma_walk->last = addr; > > > i = (addr - range->start) >> PAGE_SHIFT; > > > + if (write_fault && walk->vma && !(walk->vma->vm_flags & VM_WRITE)) > > > + return -EPERM; > > > > Can walk->vma be NULL here? hmm_vma_do_fault() touches it > > unconditionally. > > > > Jason > > > walk->vma can be NULL. hmm_vma_do_fault() no longer touches it > unconditionally, that is what the preceding patch fixes. > I suppose I could change hmm_vma_walk_hole_() to check for NULL > and fill in the pfns[] array, I just chose to handle it in > hmm_vma_do_fault(). Okay, yes maybe long term it would be clearer to do the vma null check closer to the start of the callback, but this is a good enough bug fix Reviewed-by: Jason Gunthorpe Jason