Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp33412531rwd; Sat, 8 Jul 2023 11:14:32 -0700 (PDT) X-Google-Smtp-Source: APBJJlFAlyNzuyqWfjMe6P8t1KVddXecG61V5KEwEOfj4LeBTigbwuTgXMGe74/ZLMJNLyhcPA6v X-Received: by 2002:a17:902:cec6:b0:1ac:7345:f254 with SMTP id d6-20020a170902cec600b001ac7345f254mr10128994plg.33.1688840071694; Sat, 08 Jul 2023 11:14:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688840071; cv=none; d=google.com; s=arc-20160816; b=fWxUmTg5k7KmKTpQAjg80wcuWHzVnJ2XDLrq3RTVQnMNlnHVyLkr/MIV/y1JWlICZE KzxzSMVbsmOsHSTBNK+Z78KMNPtJ7ck/nWf5ttOuk3h5e++9C5GknECD/SQM/3SIA9ws NuLijI6ORBqR5mVKspVvUpO/LiaEpNUjKAPMBJ6/Vvn5i57hqtUFbhcDJ+eFyruJ+RTu nflvzzco2NgztC717+12CaVu1S7fGDNn68H7UT9qijpqYL1wCstbVE+tMbhWs5MJWyMB IjZFWdBkDttmCi9jze137F7OKeQBQEdzlvAwCTpsJXXv/OJtNEMC+MBZklM8kJuK3p2J NAVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=KYD6jlXBis0p+PBTKlv8qzvLQ1gqj2dZYI23tZfDs+4=; fh=LJV7HDw9lqRRZRU8rm7ffuAS4PxZQHyN/w4NGyPPIug=; b=oQMHhZGMw/ZAjMzRRH+Rex1KKgABKH5fDj8wdxPYibvRqQGIg5X64qDsI7mywaOoaa C6oUDNWPUAu+8O7lfrdQPC0tIonB0LpOTAr9iHs5ceYGMG8YkK3qEuY99CoPCHV6mD+R rDcOLmtXh1rpFqgWVbKMewABom2ICC8Q+h9cb6xkocRHHcS5MhF7Z87JypEwSVHnAxvW J8VFjeEMFa9OxSR0ZEqAroKJEb7jCA3Dx9v9Rmssdicsg7loUNzc1w+7r469eR5koTLc zXJaEuzgkSy8sbdUGgsa/ja43FIaqojznqWKY029RrqblEbu3AFTyczwenPvCrRau3gP n5VQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=QzeQwAce; 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 kp3-20020a170903280300b001b86dd825e5si5538195plb.243.2023.07.08.11.14.07; Sat, 08 Jul 2023 11:14:31 -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=google header.b=QzeQwAce; 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 S229726AbjGHRaG (ORCPT + 99 others); Sat, 8 Jul 2023 13:30:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229483AbjGHRaE (ORCPT ); Sat, 8 Jul 2023 13:30:04 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48FA6191 for ; Sat, 8 Jul 2023 10:30:03 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-307d58b3efbso2948941f8f.0 for ; Sat, 08 Jul 2023 10:30:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1688837401; x=1691429401; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=KYD6jlXBis0p+PBTKlv8qzvLQ1gqj2dZYI23tZfDs+4=; b=QzeQwAceDJjVXJvGJM+3WucNS3YwkJuqcjbVwBANp9B0yMPX6R+mPsBtM7EmTqinwO JDbtzZwZMizOiOl7fV7piKWPbwokJSlqBFiq4V9vWh/dTGbk4ezsUKKlbbj/sW9ieE+g T8gQKKc3AlrB4ZvceyWg+gm3K6DJ5+evwa4Cs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688837401; x=1691429401; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=KYD6jlXBis0p+PBTKlv8qzvLQ1gqj2dZYI23tZfDs+4=; b=NGNzuseruZF5ANmaGoiHFRlZ2yGjfd5aTffj/tBMeXiPtp4MBpo6s9HoKqEdFNhdBy 6HzPi7Laz/HwSpWoAiWKO1/5Og0xIgq6F0cR301414fxt3hecAfb9SDErvRunK4YgZQj VMsnhGXopiRR9RJ2HxXXZylutGP+V2uAjIEc7h1O+/yvXykEsUcXEJFne06/dyTtYuEC Lh+/CZQr+2gh+TAhWlIkaFjiRpEypNPxqjCWUzV9XwpnmVvrnfbcqbwnOIoXT/cbqkoW 36XEnffVXE+2ZyQmRnxj5pd+3jM/VQx9DrwD7mE7X1aoLaufOCIdT9UFv5LJkiFIT//p YRFg== X-Gm-Message-State: ABy/qLa/NpRdoJ1yL/2OtJ4obAQG0VVeqgzb/LLa1QTDaVdbqIsPaqdv Fz3g7HKGUmIyzCc6kKSBtlwU6v+eJnAAD2+1Dh7wrjdb X-Received: by 2002:adf:f0d2:0:b0:313:f07b:801f with SMTP id x18-20020adff0d2000000b00313f07b801fmr6085359wro.44.1688837401654; Sat, 08 Jul 2023 10:30:01 -0700 (PDT) Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com. [209.85.208.47]) by smtp.gmail.com with ESMTPSA id e15-20020a056402148f00b0051e2cde9e3esm3498425edv.75.2023.07.08.10.29.59 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 08 Jul 2023 10:29:59 -0700 (PDT) Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-51e292cf214so3869882a12.2 for ; Sat, 08 Jul 2023 10:29:59 -0700 (PDT) X-Received: by 2002:aa7:cc8d:0:b0:51b:e4b4:8bb0 with SMTP id p13-20020aa7cc8d000000b0051be4b48bb0mr5997528edt.2.1688837399295; Sat, 08 Jul 2023 10:29:59 -0700 (PDT) MIME-Version: 1.0 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> In-Reply-To: From: Linus Torvalds Date: Sat, 8 Jul 2023 10:29:42 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Fwd: Memory corruption in multithreaded user space program while calling fork To: Thorsten Leemhuis Cc: Andrew Morton , 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=no 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 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? Linus