Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp6027789ybl; Tue, 27 Aug 2019 13:17:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqxcArE67Va2hil7Ct6ALGOHBuzoKT8cvZHZF6D22+HUVyrZDqtBRRUfyhhi5rPCmDRf5YIm X-Received: by 2002:a17:902:8f95:: with SMTP id z21mr749723plo.42.1566937045397; Tue, 27 Aug 2019 13:17:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566937045; cv=none; d=google.com; s=arc-20160816; b=DC0KimEfxQCTLBd0HrBe846ty9Rv/7+nFEKt72vS5y59Ft4uB9b1kALGnb/3Jp7Izr BuHVJys2vrD+xRomIdchpGI67Ty7KIIcR9gaeK2XWDqIzSF+e0VTwCARWVDBuSTbPPUh EiM94xk6sI6DQafbl9E1bJBsAErpKN7GMPTt4Ns2d+GZBTTTe81dlJ83zjog0QgG32DY ZsjQF8USspXD0JUxy+paXmQjoQUCAk2iWe4NnJYzxM+SxzTBhQjgp3ovigKZDjoMW7j6 wlzC9qyV7doK6CZGuHOAwuHgk75/VuS4le0D61Jxt6hGotsgty3penUsqTUOjYWPzVDx K68w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=62vGPIEVS329R8EcQsp55qtpEj1Wy2MdKSgth1zICoc=; b=zPUn4Zag212KQ5QivwXrA4p5zv7VRnKkLLIKoVlgWA6pDiObSmdjNL7NlUxQtIVOQK fYGhzVbvF1KxKL9zji0vT59sUrcnNukhF51W/Ix29t+KXOod0+TldZfhCj0978HFF4tI yzx96DR3O15LIgnGzf3YrYGDsWjiwkpsHVy+ZPplQmtZLsto/Aogc0r6C5QTA79K3Uk6 HCbrftLCrFAYXnbNosIMcnN8Zs6kMAiAQiBWSEYeRF3YFBn6/nUKn+bpS56BOdDmcCOy SAFQhQ7vakWqKHuLm6+47NgdzK7n348cMHeDsIjGaJ0c7ScFPg/Jo9krUEQMc1aP6BJx ah0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=mVWKFws1; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x184si248320pfb.24.2019.08.27.13.17.09; Tue, 27 Aug 2019 13:17:25 -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=@nvidia.com header.s=n1 header.b=mVWKFws1; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731278AbfH0UQO (ORCPT + 99 others); Tue, 27 Aug 2019 16:16:14 -0400 Received: from hqemgate16.nvidia.com ([216.228.121.65]:10286 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726871AbfH0UQO (ORCPT ); Tue, 27 Aug 2019 16:16:14 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate16.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Tue, 27 Aug 2019 13:16:15 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Tue, 27 Aug 2019 13:16:13 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Tue, 27 Aug 2019 13:16:13 -0700 Received: from rcampbell-dev.nvidia.com (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 27 Aug 2019 20:16:13 +0000 Subject: Re: [PATCH 2/2] mm/hmm: hmm_range_fault() infinite loop To: Jason Gunthorpe CC: , , , , , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Andrew Morton , Christoph Hellwig References: <20190823221753.2514-1-rcampbell@nvidia.com> <20190823221753.2514-3-rcampbell@nvidia.com> <20190827184157.GA24929@ziepe.ca> X-Nvconfidentiality: public From: Ralph Campbell Message-ID: Date: Tue, 27 Aug 2019 13:16:13 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <20190827184157.GA24929@ziepe.ca> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1566936975; bh=62vGPIEVS329R8EcQsp55qtpEj1Wy2MdKSgth1zICoc=; h=X-PGP-Universal:Subject:To:CC:References:X-Nvconfidentiality:From: Message-ID:Date:User-Agent:MIME-Version:In-Reply-To: X-Originating-IP:X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=mVWKFws1HRjcwMU4KK1X7p1o8yonqFQ3zcqupn0zPr5oGsS/Nhvvd7U/tPbwZwAKu d4ZvKn9dlm8GRZaZo3GoGEUAhJEY4j2rxqDh9fRMAyKnIdpSvp/4gSN18uzPgTC3D+ LCNkfwT6+mHkxzSajlnGlbb9pZwCxUSUmGk8cyg/TQvNQ3Yc4oI5+EhyMvw18cN9qG 8gRZsKwWbJWVYUfmGLzf9oSNdx/aOV7wufOur1JtTdi8Ef46rMoQ09VwFP84JVX/x7 Sv8gB56HOLq0NoOPFdlcxpEMIttHaJTgCBnTpEGfDbQrxsw5uIH+qeHcstowwDqfQR ENGgtWLuJWA7A== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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().