Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp611557rwb; Fri, 4 Aug 2023 19:50:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEo5gl0/IC2C+qsZyE7yFeFZIybxM3LmsVoKBIfvSesU90QVWa9vilQypHNnbJRDfsiQExb X-Received: by 2002:a54:470f:0:b0:3a1:c93c:6d28 with SMTP id k15-20020a54470f000000b003a1c93c6d28mr4252058oik.23.1691203856722; Fri, 04 Aug 2023 19:50:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691203856; cv=none; d=google.com; s=arc-20160816; b=E1/kicPNBSLrt0NZv8e0pOCVUca7DZ6F0hpmVBSDcgK07QWqQ0APn6XlociiBdGxp7 9A2N+ubYo3BMJiVKJh0TmCt3T5T6DdMUG0XDWZOzI6m6OSojO48UJF+DCnAn4lqFElcA i1uMK7AVXTweFAiUpB77cNSyjNpdD94gpjgQfG8veC8XnXYLIPcEQg/RWzz9Ij1m7jse Z4CKCSVThKD6gteCBpZhhV6Eg+uT3pEbjM6TBHIfiJy0epMlmf/vSArrjbU+hVBucaXY ZVMp+SjhOqyvH4Si4siUo2pf3LPZjEGVA6PcbCVmH0bALBm8a5s1wE+zd3wjInXf0XKd uERg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:references:in-reply-to:mime-version :dkim-signature; bh=cu168Y9vRpg+vzxEgSTGxY5n1ZLC+DuEViAjXzgPHZs=; fh=mgcwwb6fMDTH2Ig8MSyEHsUkFaKp7ge79BAu/se3mwI=; b=HuirmHvVI+rE7aWabzRaYuKzMX5ClTTDSSW1m09NqTj61/ywpCINejz+zCYWL+M6wH UpenrKCyw10yBZsVJDPZ78NPvfQmNjx9pwttH54ewiDz+VgwVnzhVTuxUHdCBpUmFeWb l7MtCxya/mV0uRm7+JfZEMPwaF5dG0n5LQYwfv7+uSykPV92qDPczZyMvgg1uD27oNi5 zFtFw+MIwHl3gvYjx7IW1o2H/t0TbOZroy1rvPXn908kp9dGNq/E7BW/n07cqQvP+P/9 A6v2oV9i1HL4cQLcsSdTo8SVEPaPZcazYg3TAiDoevurE/FdpwMHWfTBaFzz8SpkE5dL n+cA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=folnjqF0; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f8-20020a056a0022c800b00682acfc5dacsi2691552pfj.53.2023.08.04.19.50.36; Fri, 04 Aug 2023 19:50:56 -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=@gmail.com header.s=20221208 header.b=folnjqF0; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229644AbjHEBRC (ORCPT + 99 others); Fri, 4 Aug 2023 21:17:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229566AbjHEBRB (ORCPT ); Fri, 4 Aug 2023 21:17:01 -0400 Received: from mail-ot1-x32d.google.com (mail-ot1-x32d.google.com [IPv6:2607:f8b0:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B60A84EDE; Fri, 4 Aug 2023 18:17:00 -0700 (PDT) Received: by mail-ot1-x32d.google.com with SMTP id 46e09a7af769-6bc8d1878a0so2306303a34.1; Fri, 04 Aug 2023 18:17:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691198220; x=1691803020; h=content-transfer-encoding:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=cu168Y9vRpg+vzxEgSTGxY5n1ZLC+DuEViAjXzgPHZs=; b=folnjqF0aKRuew+xhfxHFYWs8LU+t5rP5KIRDLS0LazdBGhH9vtd1rk3BObzT3m5/y ukLp+VvYZQ4Ov8BDfr5g28AkAWB4g/hxW1Ssb8KRkKEt5RbkmTW2rc739qTXAxeDDDUE iIwn+0jXiPiqotQdwWEEf4v2EV8llX8EjhKSrtIZFTH7mwFarOlyk1wE1w1aDt0GwCX9 2i9+2hZ2zwdOB7u07/U9V1zz19XN4xpjHrLB6dRkyuWahGPwMFFO19gkHFqsD51e7KcF SGCnklBW6xXIGZNAIl9Y7eHS6bVtNiEuidNQcV2Z29dq9T8Xtl8zifCjWsz1/ZOz282N Y2sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691198220; x=1691803020; h=content-transfer-encoding:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cu168Y9vRpg+vzxEgSTGxY5n1ZLC+DuEViAjXzgPHZs=; b=iz8RKmMZF8DB0jbMi7s1duK8dzESL69dnlbi1fInYj+yAfW00wX8YAJfzcvc9DtocB +705fpAQ3Nk6/b/QEL6myodj97BMti1T/npXlML1J1US8tvyetBovNGvduZMLpjyLfh2 QPPTzoMzoOHCsuJyOa2CJ+7pxCSE/mTIrf4mrdV0k5/9ZzQxlXZhpsApyU3ZOCjE0RNr S1NGXxsr/XH6pJsb8ASOAEssvKfahEY2CyVXYQBfdD15zAxTRyIg1lL1ivOVI0huA0+1 4m4ykVzqCWSuY8v04NXi1SOmk+pbquXmRvlR5rN6DegsYNLoCMk9anHTdCaRtdRs64/n 7xOA== X-Gm-Message-State: AOJu0YxpN8rvPwt1V2Wc4S6Q0WwCwgRk5yQPJUzZo4XsBLBlmdIsgDUh Ww/P/B7EzRlG8FHfEz2gbKtjEdMDtAEOcmIgcDY= X-Received: by 2002:a05:6870:ecac:b0:1b7:2edd:df6d with SMTP id eo44-20020a056870ecac00b001b72edddf6dmr3872658oab.10.1691198219991; Fri, 04 Aug 2023 18:16:59 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ac9:7b87:0:b0:4f0:1250:dd51 with HTTP; Fri, 4 Aug 2023 18:16:59 -0700 (PDT) In-Reply-To: References: <20230708191212.4147700-1-surenb@google.com> <20230708191212.4147700-3-surenb@google.com> <20230804214620.btgwhsszsd7rh6nf@f> From: Mateusz Guzik Date: Sat, 5 Aug 2023 03:16:59 +0200 Message-ID: Subject: Re: [PATCH v2 3/3] fork: lock VMAs of the parent process when forking To: Suren Baghdasaryan Cc: Linus Torvalds , akpm@linux-foundation.org, regressions@leemhuis.info, bagasdotme@gmail.com, jacobly.alt@gmail.com, willy@infradead.org, liam.howlett@oracle.com, david@redhat.com, peterx@redhat.com, ldufour@linux.ibm.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, gregkh@linuxfoundation.org, regressions@lists.linux.dev, Jiri Slaby , =?UTF-8?Q?Holger_Hoffst=C3=A4tte?= , stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS 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 8/5/23, Suren Baghdasaryan wrote: > On Fri, Aug 4, 2023 at 5:49=E2=80=AFPM Mateusz Guzik = wrote: >> However, the other users (that I know of ) go through the mmap >> semaphore to mess with anything which means they will wait for >> dup_mmap to finish (or do their work first). I would be surprised if >> there were any cases which don't take the semaphore, given that it was >> a requirement prior to the vma patchset (unless you patched some to no >> longer need it?). I would guess worst case the semaphore can be added >> if missing. > > No, the only mmap_lock read-lock that is affected is during the page > fault, which is expected. > I have difficulty parsing your statement. I am saying that any 3rd parties which can trigger page faults already read lock mmap_lock or can be made to do it (and I don't know any case which does not already, but I'm not willing to spend time poking around to make sure). One can consider 3rd parties as not a problem, modulo the audit. Past that there does is no known source of trouble? In my original e-mail I was worried about processes up the chain in ancestry, perhaps some of the state is shared(?) and the locking at hand neuters any problems. I'm guessing this is not necessary. Bottom line though it looks like this will work fine? That said, I'm not going to submit a patch I can't confidently defend. As I did not dig into any of the VMA code and can't be arsed to audit all places which mess with "foreign" mm, I'm definitely not submitting this myself. You are most welcome to write your own variant at your leisure. :) --=20 Mateusz Guzik