Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp266134rwd; Wed, 17 May 2023 18:21:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ523J+iUApzCkuDUZB6DyDkWc2zr763u1XfdHkMWYnGXHOLm4JIUZr3jbEj6h3kcW9DEFnf X-Received: by 2002:a17:903:26d3:b0:1a9:b8c3:c2c2 with SMTP id jg19-20020a17090326d300b001a9b8c3c2c2mr828060plb.37.1684372915114; Wed, 17 May 2023 18:21:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684372915; cv=none; d=google.com; s=arc-20160816; b=s0ekaZrdvgIBB9/cTsrBfbRVKafwtZDVIqVeN/+PkZOMmTRma1Ogw7MDI2MhqmrguB GPGK8s/WAuiTp/yJLv8IF8O6VAxuqXJdAnopW0kQgKHknleVJdrVp7w649Hekc6ui39h MwG6aI60COgMXUDIu5GLtgK06xeCMasJ/hFCpZlR6IO/lFsLQuH4/J2naAJknQNLSd7Z 7J7184QQgdWryorOzwlzzlDKPtSo+Ikp+6LU3yy1J/XP10sqKkeVYERs/Ua8FSLY4IGs cedRAKMuVZVLX7OtePedvfzaefFRSn2f5Ylj+uHXYQ+kTE5UxkzIXlYrTp6hB/EdYOT/ wc/A== 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:to:from:date:dkim-signature; bh=4YL4VRHTTTP5ymMEYgQSrzIpXej5X99LgoW1v1ye3Zo=; b=xdSMQbDHcwkwJJpiXnb4PMxK3pDe8HWc71sIV0mFLJQ4NbaoIVHKjAT2G6J4bD6JYm bVf/F4byRkT8gA9XIw5g7cZTlDZfZheBY6Ct6c4SjwF7vOodEVL7cBN2PzSlMiQB89hr VBDDv/jQeciEq83b7jORE+Is2JFODal6DwLRHiO+tO19O7oQjikoCsgShv/oJGUu1HnM bqst1kYIb2Z91goFEe1G9IvpHij2wY13+pcTtj8bCb+sS/lBGDM+096vSoy3I7VhDrad TRCpOaQTWNrz97wQzhvxSTcm9nZtwR80VYyDXslyvttRvsgRdQJvPKYY//zv8ckZSNdF G1Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Wqbnx7kA; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f15-20020a170902ce8f00b001ab01ba1f89si9756plg.452.2023.05.17.18.21.43; Wed, 17 May 2023 18:21:55 -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=@redhat.com header.s=mimecast20190719 header.b=Wqbnx7kA; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229607AbjERAjo (ORCPT + 99 others); Wed, 17 May 2023 20:39:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229482AbjERAjn (ORCPT ); Wed, 17 May 2023 20:39:43 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA67B30C8 for ; Wed, 17 May 2023 17:39:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684370339; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=4YL4VRHTTTP5ymMEYgQSrzIpXej5X99LgoW1v1ye3Zo=; b=Wqbnx7kAus3cyNZY2qtkbydf2GDi0c9pUMCaGiAO/XFO1ZOrtmx/q12gkDpLeQIlfpTtfj 0AidY7BNKRz7Dqcu8pTuDfYVnNQOGTFXwiUXf6pQdZHVNgSe5fbqKDz8gK2vQMs60gNF26 1EO9jEizTXvB10zSqZlSxhk1kUlfh3g= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-151-Etr3ADirMnmvkUeJGEwywQ-1; Wed, 17 May 2023 20:38:58 -0400 X-MC-Unique: Etr3ADirMnmvkUeJGEwywQ-1 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-3f398a25be2so563851cf.0 for ; Wed, 17 May 2023 17:38:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684370338; x=1686962338; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=4YL4VRHTTTP5ymMEYgQSrzIpXej5X99LgoW1v1ye3Zo=; b=LJaCbAgOiMuUpMjFrNhKHD5U7CR6wQgcOjL7dJQHHTls7jFHMNw9Mb9XvvWphd/Bwv UMwaVAh/sLJM8v/+V0WkCq1ChkrxBajZwK6zGE6Nao9yPYqLCacG6+rhe9E2VLeeHCv5 1J/3cXtyHA+fVlCouKKi+gDAilDHiakm2qQ2Whd/+jaYGy1tkBOweAFCqjo9hMpOY3nP 9E+3EvDLCgD9IvgAF/n0XgH5Nx4pKX8tloDSZc+1FwchrlTJoMFPbLH7eAgucMz8ECq4 D/869C+Lc2+AzH7fzLORR0MXg5/5qUT+yUtm0Ijq+8rOEapEsddByfJOAgOJT/VxUUrX oFJw== X-Gm-Message-State: AC+VfDxu5wpuOSApEFOl3J/evt2EQfQROnvzht4concFWjhb3564eG0i SeuSCZbrXHqpEwae+fvb2IXUcqSga+Sn/9ZqZ33Feh+PO8rZj5ath/+n+fY9//dbCHvq68S7pCk awDYoo4Jnr9lRfILY/p/PVtjg X-Received: by 2002:a05:622a:8f:b0:3f2:38d:5c84 with SMTP id o15-20020a05622a008f00b003f2038d5c84mr8822018qtw.4.1684370338063; Wed, 17 May 2023 17:38:58 -0700 (PDT) X-Received: by 2002:a05:622a:8f:b0:3f2:38d:5c84 with SMTP id o15-20020a05622a008f00b003f2038d5c84mr8821999qtw.4.1684370337824; Wed, 17 May 2023 17:38:57 -0700 (PDT) Received: from x1n (bras-base-aurron9127w-grc-62-70-24-86-62.dsl.bell.ca. [70.24.86.62]) by smtp.gmail.com with ESMTPSA id j17-20020a05620a147100b0075934be7618sm40063qkl.71.2023.05.17.17.38.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 May 2023 17:38:57 -0700 (PDT) Date: Wed, 17 May 2023 20:38:56 -0400 From: Peter Xu To: "Liam R. Howlett" , Lorenzo Stoakes , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Mike Rapoport , Mark Rutland , Alexander Viro , Christian Brauner Subject: Re: [PATCH v2] mm: userfaultfd: avoid passing an invalid range to vma_merge() Message-ID: References: <20230515193232.67552-1-lstoakes@gmail.com> <20abea10-5307-498b-b9df-8f0b2fed1701@lucifer.local> <20230516164907.5bf2qe7nn5bo7iaa@revolver> <20230516225251.xwmz2oyebo7k56ys@revolver> <20230517225142.xbchqdmp6ma5wzkg@revolver> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230517225142.xbchqdmp6ma5wzkg@revolver> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 Wed, May 17, 2023 at 06:51:42PM -0400, Liam R. Howlett wrote: > > Yes, IIUC that's what we want because vma_merge() just handles everything > > there (including split, or say, vma range adjustments) if any !NULL > > returned. > > I don't get your use of split here. __vma_adjust() used to be used by > split, but it never split a VMA. vma_merge() is not used by split at > all. I guess maybe I just made it confusing somehow when using "split" here.. I meant the vma range adjustments when vma_merge(), so indeed it's not really a split, but it's still a logical split to me. To be explicit, taking example of the uffd unregister case that was essentially case 4, where part of PPPP will be "split" out and merged with NNNN: **** PPPPPPNNNNNN might become PPNNNNNNNNNN case 4 below if (prev && addr < prev->vm_end) { /* case 4 */ vma_end = addr; adjust = next; adj_start = -(prev->vm_end - addr); err = dup_anon_vma(next, prev); ... } PPPP is adjusted here (where I was trying to refer as a "split", because vma_end is less than before so part of PPPP is cut out): vma->vm_start = vma_start; vma->vm_end = vma_end; vma->vm_pgoff = vma_pgoff; NNNN adjusted here (where the "split" part merged into NNNN): if (adj_start) { adjust->vm_start += adj_start; adjust->vm_pgoff += adj_start >> PAGE_SHIFT; ... } I'll remember to stop using the word "split" in these cases in the future to avoid confusion. Thanks, -- Peter Xu