Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp133535rdb; Fri, 29 Sep 2023 20:56:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGpdIJ/fYrSrUmIvF6eHNvz9tzhnX8Js9W5Jl7iLJOhZhxdZLWGew30IKGJPSMgMG4/rb5n X-Received: by 2002:a17:902:ecce:b0:1c6:2acc:62d5 with SMTP id a14-20020a170902ecce00b001c62acc62d5mr6845497plh.22.1696046174395; Fri, 29 Sep 2023 20:56:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696046174; cv=none; d=google.com; s=arc-20160816; b=Vhxz05w46lsIt+HZao37vsXGmFnahPj3v1TjZy1LO5OMyeYyXtB8Yaj3O6qt3neoxn p049YRKw0PWn4kiGR4q+HV07SNCSNKj3rjARzW4TE6FodlLahOQaWwuv4kTSAligWrKH qYsfaEug4mvSHbloHwKHpgSrpFH692aEOSGpnZpaIOusymx7PvuejbsXuaSL9PZPn+rt sp6TgKVp7Z75TUSXTUuF9AqWitvLlATOsgn85LPJ35JDdKlfeKz64VP7bamWlT5SYv3I iJHLdCHh/Mdwo6pPtX6i//63f7NB3oy17ItdA5Kkto7Vspm+Sxg53cbp+Uv2bURvAVj1 OcgA== 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=J4ODyI/xGDfBDr3VSCKLFMfeRUTcBjJWMeC4Qx7RcLU=; fh=7s+OQPkuqQ2n2ahi4EtVH8syAkYQMAN81ZiY9DztoDk=; b=I/wggHdHlY+0p28lZ3gVMzjGXzqTWAbXjjepBxcb6nADSOQtTBqcvmroV49Fd0rJgU nl1PgKb3sex8Jr3UAsw/7ojKsf3ZLFJfysrc//+MmkVYYnF3Rd88wN4FQp+r8Ud0WTmh B/MczeERoeYUftXyvdcOTTcvWN8v6uUHQ3NnGSUqkDWG8IC12r2P+Ep5BYq/9ZVJLazj ipFjlf7hp9yjmmt+pRTUq/HTPi4pufPa41cBKuJ7e59G5vFEKAm0fNqh+XWkEzfM27h4 4TTFLgrpdtxLzNJnpt6k7nUiBrGerFs/Wxw0ySqbRkcfR2COmpOlsWCOBv0erLEiLKkA 4r5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="ceYZ/TRY"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id lg7-20020a170902fb8700b001c60d1de681si14987282plb.108.2023.09.29.20.56.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 20:56:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="ceYZ/TRY"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 0699880990CA; Fri, 29 Sep 2023 15:30:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233634AbjI2WaI (ORCPT + 99 others); Fri, 29 Sep 2023 18:30:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229508AbjI2WaG (ORCPT ); Fri, 29 Sep 2023 18:30:06 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CC98F1 for ; Fri, 29 Sep 2023 15:30:05 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-406650da82bso1602505e9.3 for ; Fri, 29 Sep 2023 15:30:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696026603; x=1696631403; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=J4ODyI/xGDfBDr3VSCKLFMfeRUTcBjJWMeC4Qx7RcLU=; b=ceYZ/TRYjzLJMUz9TiOyb16DwNx7ybYKb1RzxSlCxtYlM5LLHg5AFVcRxF1sQKfW6R PvJPxTxvA9x2uMb8vY3a3Gj/2t7/H+opZwDi41Hlb4zmxc7ydobYuy2V0G3r3F4zW1yI j98hv5ZDA6BE1a0FhVbdOwxZEWd85AIXufTrlkVy2FU11ER0nn3AknFSPeWD7V69wK9Z zNBMfgIcTMnbw4qX+SS/QWxbmFedBRAkiheCZVOojUuywWC4oLYL+rKetg9SH85E/9zR 3ZCtUQBKwtDRqQ8FvqbBBRwftf40X8CoVfPlPI/zk0l3xXNfMKNsDWngolHWTfzxN4Mg rTaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696026603; x=1696631403; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=J4ODyI/xGDfBDr3VSCKLFMfeRUTcBjJWMeC4Qx7RcLU=; b=WFkU+upjcgH4DvcBKeWoFzaAsq1r21upIuiVOeb0LmlPaYS7RF8ml//mHIevWQTWtO /AoxBq8a0+egWgR/VN9OVCjER/SOQR/RRL53i50rsor54zsauFGx+CZGz/JKDzhKjdWK jVrGl5lXavtgRAUovAyjbcYY5slZBM7hd+QKP3QjYyOjVNd+jeSCfqw0CjorVYqFKCQ/ zt85WqOa/epjB1nusUzB4BMDwDaBL+wxJx26LjwWOd7CrAP/euzEWce8b5bEJ5qLh7ju gubzRMuxqDlCgr0l8qB36M+Qy54cuc2u3MeC9xH0NlOMDv6lokFf9gheH4ozCVHO/U4v 2F0w== X-Gm-Message-State: AOJu0YwclrOD81mX1Egi2bunbaTxlnpXRSMg++Cg8G3wQGzkFIaqkeSK zjUpgYCYj3EtdlG0D0JPI/g= X-Received: by 2002:adf:ea49:0:b0:320:485:7010 with SMTP id j9-20020adfea49000000b0032004857010mr4620006wrn.67.1696026603166; Fri, 29 Sep 2023 15:30:03 -0700 (PDT) Received: from localhost ([2a00:23c5:dc8c:8701:1663:9a35:5a7b:1d76]) by smtp.gmail.com with ESMTPSA id b4-20020adfee84000000b003197c7d08ddsm1555572wro.71.2023.09.29.15.30.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 15:30:02 -0700 (PDT) Date: Fri, 29 Sep 2023 23:30:01 +0100 From: Lorenzo Stoakes To: "Liam R. Howlett" Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Jann Horn , Vlastimil Babka , Suren Baghdasaryan , Matthew Wilcox Subject: Re: [PATCH v3 3/3] mmap: Add clarifying comment to vma_merge() code Message-ID: <1c7c1869-ef9c-487f-9c8e-08a51d9f8efe@lucifer.local> References: <20230929183041.2835469-1-Liam.Howlett@oracle.com> <20230929183041.2835469-4-Liam.Howlett@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230929183041.2835469-4-Liam.Howlett@oracle.com> X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 29 Sep 2023 15:30:41 -0700 (PDT) On Fri, Sep 29, 2023 at 02:30:41PM -0400, Liam R. Howlett wrote: > When tracing through the code in vma_merge(), it was not completely > clear why the error return to a dup_anon_vma() call would not overwrite > a previous attempt to the same function. This commit adds a comment > specifying why it is safe. > > Suggested-by: Jann Horn > Link: https://lore.kernel.org/linux-mm/CAG48ez3iDwFPR=Ed1BfrNuyUJPMK_=StjxhUsCkL6po1s7bONg@mail.gmail.com/ > Signed-off-by: Liam R. Howlett > --- > mm/mmap.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/mm/mmap.c b/mm/mmap.c > index f9f0a5fe4db4..9967acbd070f 100644 > --- a/mm/mmap.c > +++ b/mm/mmap.c > @@ -943,6 +943,11 @@ struct vm_area_struct *vma_merge(struct vma_iterator *vmi, struct mm_struct *mm, > vma_start_write(curr); > remove = curr; > remove2 = next; > + /* > + * Note that the dup_anon_vma below cannot overwrite err > + * since the first caller would do nothing unless next > + * has an anon_vma. > + */ > if (!next->anon_vma) > err = dup_anon_vma(prev, curr, &anon_dup); > } > -- > 2.40.1 > Nice comment! It causes me to sick up a bit in my mouth that this is a thing, but it's good to have it documented. Reviewed-by: Lorenzo Stoakes