Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp585711rwb; Thu, 27 Jul 2023 18:25:33 -0700 (PDT) X-Google-Smtp-Source: APBJJlFoDOAcDboj6fAgeX2vJgBhwdcgaVSGeyiw7u8KYMrDQFmZoU19z1+uVbh4FWGyJiqih9OC X-Received: by 2002:a17:90b:3141:b0:262:e1a8:7eb0 with SMTP id ip1-20020a17090b314100b00262e1a87eb0mr195262pjb.39.1690507532857; Thu, 27 Jul 2023 18:25:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690507532; cv=none; d=google.com; s=arc-20160816; b=V0qW+xOXWgpLeqHC/P1/aJ5Lwz72YKYwewJF+vQe2uqbucP7fQcZrCI6DhiDFpJjpP DbL9x0dAP0rW515RVCfCjLoFIczNwWAJBYdz/Kx8WOn3BoVMjv4pmdtoq5aqUAe/yvkW SloaXI22QvvV19ckbs2q96tYYSumWPXeNeh/Ox0t5KNjCYzU5fBb1Rn4lM5dtJyNLort u8uICPuhl/qFkbknCYPQ0LMn5ZnJRXvb4BtguVeMagDnnZxRYcdvc9R8NmLcP4EpS8Qo edXrJs98QsZ1V9/OXbO/5hKZarTX1SnZ1mV3tk0wvXQdtN3gZ2sxHFP0hgm64i1N9cqf JAAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=dDKW57DuKsQQ6wWR5XrMKt3UcRI5urTH+VZ5eCSrvyA=; fh=ZTRI+9X7P9dJ4N+EXS3eq1gQdRhJ1emtzAUx1Krsaq0=; b=ffZapKxA8iJjVwmsTCXJD3OYPPC9lggDndra03XA4pmk3IJhbcXyQQZDl1NVwggPc7 Cq0edLUjPf9qWbM5Hg6FfH+tm/3kCy5iOSt8+kf7LN6Pd2wXLyiUwcsSQv0eSdfpD3lB xfRomVOWa9zgcFpQfDA1pRML6s/0M5P3UBuRF7xsH3AVpo4l0IXguGuk3hcfblZm7JnG U5HYwsxPJij94Z0psAHFhM/bSn/DZ9nYdagL4t99axVk0zKrVfuH4XsjECg2l2NQvkLy 4y8tRaDwt4BIjQzxlX0w9/8OOxPij4tMrvVPMA2JoBhVIO5TQas1AW4m39YR6XJPGvQD PEhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=kdBy7GEU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w8-20020a170902e88800b001b8a4519706si2229937plg.19.2023.07.27.18.25.20; Thu, 27 Jul 2023 18:25:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=kdBy7GEU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229949AbjG0XuD (ORCPT + 99 others); Thu, 27 Jul 2023 19:50:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229600AbjG0XuC (ORCPT ); Thu, 27 Jul 2023 19:50:02 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F78630F9; Thu, 27 Jul 2023 16:50:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=dDKW57DuKsQQ6wWR5XrMKt3UcRI5urTH+VZ5eCSrvyA=; b=kdBy7GEUxIVNyMDS69VXIaBCb5 7m5vxdRhAto2HIOduUMJ8tjMjBLK0E+NXPYJGQRos9AIKwyXLm9121yGS894LzH3LG1JUNGFb05eO 0IAr8LNxr/Lk6xzTbzOyQwJV/2tVB9pEUyvHdVP9wCD4z3yf+zwgofRsDAOBfEJGU9GRJbYTZp3Ja DpA5pq+NgvmAlbemoMhD2Hfey8/WOXBb4QBMTKco1gOmNAnYgznTRgLAnLApx83+rwAsGbL4kfs3O +v5vTSiTle1lbk62tfDGEmmWoBQ+idWD3dlUpZsRzcVAv3J22IGmCzFwNYPKKuiZwvK/wo6lRiu9Z Vx4icKvQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qPAju-007yk0-EE; Thu, 27 Jul 2023 23:49:50 +0000 Date: Fri, 28 Jul 2023 00:49:50 +0100 From: Matthew Wilcox To: Stephen Rothwell Cc: Andrew Morton , Jann Horn , Linus Torvalds , Linux Kernel Mailing List , Linux Next Mailing List , Suren Baghdasaryan Subject: Re: linux-next: manual merge of the mm tree with Linus' tree Message-ID: References: <20230728091849.7f32259d@canb.auug.org.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230728091849.7f32259d@canb.auug.org.au> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 28, 2023 at 09:18:49AM +1000, Stephen Rothwell wrote: > diff --cc mm/memory.c > index ca632b58f792,271982fab2b8..000000000000 > --- a/mm/memory.c > +++ b/mm/memory.c > @@@ -5392,32 -5597,18 +5597,21 @@@ retry > if (!vma) > goto inval; > > - /* Only anonymous and tcp vmas are supported for now */ > - if (!vma_is_anonymous(vma) && !vma_is_tcp(vma)) > - /* find_mergeable_anon_vma uses adjacent vmas which are not locked */ > - if (vma_is_anonymous(vma) && !vma->anon_vma) > -- goto inval; > -- > if (!vma_start_read(vma)) > goto inval; > > + /* > + * find_mergeable_anon_vma uses adjacent vmas which are not locked. > + * This check must happen after vma_start_read(); otherwise, a > + * concurrent mremap() with MREMAP_DONTUNMAP could dissociate the VMA > + * from its anon_vma. > + */ > - if (unlikely(!vma->anon_vma && !vma_is_tcp(vma))) > - goto inval_end_read; > - > - /* > - * Due to the possibility of userfault handler dropping mmap_lock, avoid > - * it for now and fall back to page fault handling under mmap_lock. > - */ > - if (userfaultfd_armed(vma)) > ++ if (unlikely(vma_is_anonymous(vma) && !vma_is_tcp(vma))) > + goto inval_end_read; > + No, this isn't right. It should be: if (unlikely(vma_is_anonymous(vma) && !vma->anon_vma)) goto inval_end_read; I'm not sure about the userfaultfd_armed() clause. My patch wasn't intended to affect that. > /* Check since vm_start/vm_end might change before we lock the VMA */ > - if (unlikely(address < vma->vm_start || address >= vma->vm_end)) { > - vma_end_read(vma); > - goto inval; > - } > + if (unlikely(address < vma->vm_start || address >= vma->vm_end)) > + goto inval_end_read; > > /* Check if the VMA got isolated after we found it */ > if (vma->detached) {