Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp33451869rwd; Sat, 8 Jul 2023 12:13:12 -0700 (PDT) X-Google-Smtp-Source: APBJJlFJV2ed78+RMnIQzIMydFVv45hWBT2kO+Ici2UeulFUzzAOCX5b5AsDn5D2DvTJ9EQR45jH X-Received: by 2002:a05:651c:1029:b0:2b4:6f70:c390 with SMTP id w9-20020a05651c102900b002b46f70c390mr6238013ljm.15.1688843592691; Sat, 08 Jul 2023 12:13:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688843592; cv=none; d=google.com; s=arc-20160816; b=WI9LClQKr6OhK6eh9ERUSE7JHTrkNlDBCQiBv74JKtN/F632ZdP7/Qo9n4G7+nuAMh pE4s2hJye3jNNNV3xJp5xpY1OE46OLCKdmuepITAQSdLhSzuP5sdK69Hs0XoB2kw0bzH WfuLpaEmMhQua2atrEptO5vLqusQqYpFGSX2ip4yilBbU1h6CEmeL47AxAH/hfyGWUSf ORlmL3JRnvcNj/oZ+vQgxT6LCtpZ1ed65khkhde+W6HFGPKUAjJ9gnKs/Jg079+UZDSE S+GlcQtnGJGM8gItBu6BGQCsNSQ7P5XejqY5VjJbBtRnAbPIL8INiDakecALJE/fTd+N wN+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=Ddv+nq9vgHR5Rjx/jvrZoh5OlVJP/ZM30tbcWDbznRM=; fh=Bmpt+R7OD2dDue33ucNpNRtSquhh9GjX4MEAWe+Kz4o=; b=Jvqq1dvOA7xsVD8cDqd9LUO/z2/efqFryP55WIz4B56MASsVq/JyS2SIdN1rk1Q30O aM/KywJyeenWWSztxjBfEQ1mqrfa5taAYNHisC5eEjHG4Uc3YwyY6uQo2E9kSttSmA/z 58j23LJksgG2G3bGkxvm55L6SJDPBG9fMFQjVhqS/uURh/6j7gUWiYHaQhKYVFt/emjU DLIWd6AVhAC0fEu5GdNdqwncX3pr9Q3OrD5xmK2wQokZdTEpg5ehU6fY37R2VTRpM0Vs j8zoXOUVK4WTfFUaLym3gKXqMWSngg4TM7C4W5j/YzrzhWQFW6zhtMnlJoeULUQpKCES yeAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b="pG41tN/N"; 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 o8-20020a17090608c800b00992cd72e0b1si3851699eje.667.2023.07.08.12.12.48; Sat, 08 Jul 2023 12:13:12 -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=@linux-foundation.org header.s=korg header.b="pG41tN/N"; 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 S229927AbjGHRjl (ORCPT + 99 others); Sat, 8 Jul 2023 13:39:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229483AbjGHRjk (ORCPT ); Sat, 8 Jul 2023 13:39:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4016FE4C for ; Sat, 8 Jul 2023 10:39:39 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B120560DBD for ; Sat, 8 Jul 2023 17:39:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE4EAC433C8; Sat, 8 Jul 2023 17:39:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1688837978; bh=drHKeMgcNL4TWp9p/P+2PrXQ+fcbGYyaIQwGHCxCj5A=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=pG41tN/NOuUi9p2O3xHgsxiCZm9Ur7qT6LNK6J41PNluKBPAFAfzwjkUk+IBoOqJ0 gYvAHLzr7CA3aWA+fO583UTJs0L4X9fZyeJsLRZhqu7fpJiCYldMckz2u+xwpVo7a4 m8F2vLyJTKNBUlLaocc7+8PhsfdYv6ml1+FfFGnk= Date: Sat, 8 Jul 2023 10:39:36 -0700 From: Andrew Morton To: Linus Torvalds Cc: Thorsten Leemhuis , Suren Baghdasaryan , Bagas Sanjaya , Jacob Young , Laurent Dufour , Linux Kernel Mailing List , Linux Memory Management , Linux PowerPC , Linux ARM , Greg KH , Linux regressions mailing list Subject: Re: Fwd: Memory corruption in multithreaded user space program while calling fork Message-Id: <20230708103936.4f6655cd0d8e8a0478509e25@linux-foundation.org> In-Reply-To: References: <5c7455db-4ed8-b54f-e2d5-d2811908123d@leemhuis.info> <2023070359-evasive-regroup-f3b8@gregkh> <2023070453-plod-swipe-cfbf@gregkh> <20230704091808.aa2ed3c11a5351d9bf217ac9@linux-foundation.org> <2023070509-undertow-pulverize-5adc@gregkh> <7668c45a-70b1-dc2f-d0f5-c0e76ec17145@leemhuis.info> <20230705084906.22eee41e6e72da588fce5a48@linux-foundation.org> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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 Sat, 8 Jul 2023 10:29:42 -0700 Linus Torvalds wrote: > On Sat, 8 Jul 2023 at 04:35, Thorsten Leemhuis > wrote: > > > > The plan since early this week is to mark CONFIG_PER_VMA_LOCK as broken; > > latest patch that does this is this one afaics: > > Bah. > > Both marking it as broken and the pending fix seems excessive. > > Why isn't the trivial fix just to say "yes, fork() gets the mmap_lock > for writing for a reason, and that reason is that it acts kind of like > mprotect()". > > And then just do what those functions do. > > IOW, why isn't the fix just to do > > --- a/kernel/fork.c > +++ b/kernel/fork.c > @@ -686,6 +686,7 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm, > for_each_vma(old_vmi, mpnt) { > struct file *file; > > + vma_start_write(mpnt); > if (mpnt->vm_flags & VM_DONTCOPY) { > vm_stat_account(mm, mpnt->vm_flags, -vma_pages(mpnt)); > continue; > > and be done with this? Yes, we could move it down a bit more, ignoring > the VM_DONTCOPY vma's, but they are so uncommon as to not matter, so > who cares? That was the v1 fix, but after some discussion (https://lkml.kernel.org/r/20230705063711.2670599-1-surenb@google.com) it was decided to take the "excessive" approach. Also, this change needs a couple more updates: https://lkml.kernel.org/r/20230707043211.3682710-1-surenb@google.com https://lkml.kernel.org/r/20230707043211.3682710-2-surenb@google.com So I'm thinking it's best to disable the feature in 6.4.x and reenable it for 6.5 once all this is sorted out.