Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2353369ybl; Sat, 24 Aug 2019 15:41:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqxxWgexLBjHHtpTbJytoxqJXl4yZ5v4hDcWmzuTaViHvvmkORDKNKxYzrl81en7kYoGOwNA X-Received: by 2002:a63:60d1:: with SMTP id u200mr9803243pgb.439.1566686468322; Sat, 24 Aug 2019 15:41:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566686468; cv=none; d=google.com; s=arc-20160816; b=ojXeOpfFXWDE+1ryD/rJJBiPxyVYEkCbPFGvGbvGDRPQ5734l3mmcDw4Y3aDs6cipV cHEnUupOJ0G4MndgdKIByhUqPMVo4DC0hWBAbH473c4z+5BX251UjsMqYm6GNhwpOIYO r9MQfM1NE/DfTLLs7u9QXh7LYEJP5MMk0/8yLA/6YlMZf4QAo5dhsWKm/YtsubFfQ1v+ aqSz3+sEdIEPeqiZGTUm6Fxh70aNQH2zknxN0dQLj4MRVxwd4qGHdXqOHDE35hf/rZra KgN/wrXsgZmIuZAfWnn+AsL2Z45I/VgBD8zaiw/s7mSQpc11CpcVRgxrlZ8XIor1hvPI RH7g== 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; bh=XnYWWxav6VsiBueCanUVOEnlqZSpUKNj5JfY9jpIxuU=; b=JvN86ojlZ72SlN0FGBZiOV+BsjXPL5rWTTPIROMzsC66wclFzV9axqwr52UAYoQtDg pNMyKgq7FZxx+ZxbfoTY6vxfOFmeFIcW+E7m7e8r7KUkHVLtHzS0Wx+6MQNrjR72HDiI enao96c+zg89fWw9uWCe6Cz5lSVeelNiG1L/ZbV4HhYDA4+lwNdnjq4/tmDhD6q2Ybfm 7TZqD0I3lNIZoD2AZ4NmrK8rj/1R18+2tdT193V+d2FHK/XS2cBzVZTARyPkNj9pp+oI kJW+OuOltk8oEhcyXQaDSiQio/d1QrmzBkSoh0yWNZOVaFY7PPW9jxddnLgpGJRwofWD 07lQ== 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 z19si6335619pfa.19.2019.08.24.15.40.53; Sat, 24 Aug 2019 15:41:08 -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; 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 S1728264AbfHXWjL (ORCPT + 99 others); Sat, 24 Aug 2019 18:39:11 -0400 Received: from verein.lst.de ([213.95.11.211]:37672 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727907AbfHXWjK (ORCPT ); Sat, 24 Aug 2019 18:39:10 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id BB04B68B02; Sun, 25 Aug 2019 00:39:07 +0200 (CEST) Date: Sun, 25 Aug 2019 00:39:07 +0200 From: Christoph Hellwig 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, =?iso-8859-1?B?Suly9G1l?= Glisse , Jason Gunthorpe , Andrew Morton , Christoph Hellwig Subject: Re: [PATCH 2/2] mm/hmm: hmm_range_fault() infinite loop Message-ID: <20190824223907.GB21891@lst.de> References: <20190823221753.2514-1-rcampbell@nvidia.com> <20190823221753.2514-3-rcampbell@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190823221753.2514-3-rcampbell@nvidia.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 23, 2019 at 03:17:53PM -0700, Ralph Campbell wrote: > Normally, callers to handle_mm_fault() are supposed to check the > vma->vm_flags first. hmm_range_fault() checks for VM_READ but doesn't > check for VM_WRITE if the caller requests a page to be faulted in > with write permission (via the hmm_range.pfns[] value). > If the vma is write protected, this can result in an infinite loop: > hmm_range_fault() > walk_page_range() > ... > hmm_vma_walk_hole() > hmm_vma_walk_hole_() > hmm_vma_do_fault() > handle_mm_fault(FAULT_FLAG_WRITE) > /* returns VM_FAULT_WRITE */ > /* returns -EBUSY */ > /* returns -EBUSY */ > /* returns -EBUSY */ > /* loops on -EBUSY and range->valid */ > Prevent this by checking for vma->vm_flags & VM_WRITE before calling > handle_mm_fault(). > > Signed-off-by: Ralph Campbell Looks good, Reviewed-by: Christoph Hellwig