Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp599064rwb; Fri, 4 Aug 2023 19:28:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF6cCA1p8awMcjmGk7H7dv8a1RLpgttnHuPxBxgOvJENLd6Xm1OfIQCWCpfIzAr+jjS3/Mk X-Received: by 2002:a17:903:248:b0:1bc:2d43:c747 with SMTP id j8-20020a170903024800b001bc2d43c747mr3885401plh.38.1691202538147; Fri, 04 Aug 2023 19:28:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691202538; cv=none; d=google.com; s=arc-20160816; b=g7SN9M250EPEmHnVDlJFuyoM+uyNcbUM45/Y42O3v5LwBx1VaqEm4bfwk5PLDvKF7m CLIIshzWZwnAiCtNRusx/thL7ymjMRVE0fZMKU2fw9Xxden/JRBL4Sl/RRy/b5PcsgAP irPcL3hQwx5hEpDj7hga2ILx48pzx9rekqsWYpJq2MOIOCEM0EVq1WsHzMp1EJRIy72R TE/xe21ttAh6i1q4C9d4iw0SMtDT0vd1Nkfy6n+DSJeQS0DdSch2+EHU3Th4Qh8IlyuL oIQrOJ8VxVBn8w+9evaC02Hlk1wSMHPyT/MHD4xNAq66Z9bMIiYQXvqks8hwPaQesFkW 0kZg== 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:in-reply-to:references:mime-version :dkim-signature; bh=AujeCo6jm3AYe4qZ6y6dt+l/y9fmf46ls+zy0ks6uBk=; fh=MyAfGONXyUqjX07eXfKS/mDPkBD0PylW2glSBuL3t04=; b=l/RxepA9cfVhzfmJMYW0xFp9mRexQxQuaVHwRCQaZhHBVaiNH3uZWvpCyBR36AzCv9 JhpfdcZ6xwPWxON56dzRzLUxt1T++Bv0wG5zO6exzi3QlXCJdOltW3k74ARX4vcS5pOs CKalQNpbulfYosRSIUR0Mf6BibmnuKrvj+UTf4sVP4hlf1SaHmWewj37Pr2sjlRiFskx IAKOHYOfEn0EIcymnQOGNLIuDYcwxSF2Sjd8blNmOdwzY9RyfS57/GQrtZXLA/zSfjh/ HaNygOzwMSse8ezwQ/ae3/ecNWhSL1Pl1H7Mfk5tz2u1Lg2zRZrjgR0gXjij6VhokeWE 0ZQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=bpswymm8; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jw13-20020a170903278d00b001b8b4330585si2475742plb.510.2023.08.04.19.28.30; Fri, 04 Aug 2023 19:28:58 -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=@google.com header.s=20221208 header.b=bpswymm8; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229450AbjHEBgu (ORCPT + 99 others); Fri, 4 Aug 2023 21:36:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbjHEBgt (ORCPT ); Fri, 4 Aug 2023 21:36:49 -0400 Received: from mail-yb1-xb31.google.com (mail-yb1-xb31.google.com [IPv6:2607:f8b0:4864:20::b31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71A3CE72 for ; Fri, 4 Aug 2023 18:36:48 -0700 (PDT) Received: by mail-yb1-xb31.google.com with SMTP id 3f1490d57ef6-d16639e16e6so2674010276.3 for ; Fri, 04 Aug 2023 18:36:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1691199407; x=1691804207; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=AujeCo6jm3AYe4qZ6y6dt+l/y9fmf46ls+zy0ks6uBk=; b=bpswymm8/aHd6mYtUujhG2QErdghxkdOBUSisUuXISL43iBt5anSiCY7npzyoUiEp/ 2r0DThfOtkG+yPEzC58xZLlele5B03sILA+y2PDwjAPMcXtkwUcFy5lrcWm18fIezCd2 TvTlOQPRw7trWWi7TFwzUQOVcXl3hZGoUY/y3/OIyQgS+g5h8gNRs0QcE+lMY/pkkoXy Ns1q4mZuMDjIYZNsw7vuvEEABh4IA+p+ZsHCspKeMOXHkfvzh6yntnLUxWpgnw8t77Vi bBEHLKcSkpQzi5wly6AOeCVeTC0b886H1B0C1idctkdvu2YXbxSIRxaC+odXZzrzeWAu h22w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691199407; x=1691804207; h=content-transfer-encoding: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=AujeCo6jm3AYe4qZ6y6dt+l/y9fmf46ls+zy0ks6uBk=; b=Vlgc6llBItZTf8tfWV/GcaHNKkRWURu35WeYKoA+n9oY+yQlpAZT4lZiufY+WwmjfG ZMllJz/cD4RhG7ECBDCzZQND/ovl7hE3XgTIJy9qIfArAJ0553wPqHOa4tRz1jOtNH7A fyfDaJo3E96B4wimGD0S9x3PAf60dwXGq8iDG5lJ4yuu9oVfFuiRYk9okUsY4/fPil32 vMYKLAS2Ag60NYhlI4PP4LP4ZMGNkQA3uFcMNQraBiI3xATuTgdOqIGiSEVcdCJO8sSE G3onl/CtTjdnQzPgTS+W8GDpiAI24Qaf83TqlEMB14Mzmw+Xbox6gYfA1OaCNJyd9WEX l8cA== X-Gm-Message-State: AOJu0Yz7r/g218sOmw5/SU3bS/thYwBj4IFcR0snWN6LvsOA1Q2qNxHt svSp3O22gfrTw5JcNlIQ2ncrN07JErzsc+e4rVGQUg== X-Received: by 2002:a25:d08:0:b0:d1c:7549:4e8b with SMTP id 8-20020a250d08000000b00d1c75494e8bmr2986579ybn.29.1691199407388; Fri, 04 Aug 2023 18:36:47 -0700 (PDT) MIME-Version: 1.0 References: <20230708191212.4147700-1-surenb@google.com> <20230708191212.4147700-3-surenb@google.com> <20230804214620.btgwhsszsd7rh6nf@f> In-Reply-To: From: Suren Baghdasaryan Date: Fri, 4 Aug 2023 18:36:34 -0700 Message-ID: Subject: Re: [PATCH v2 3/3] fork: lock VMAs of the parent process when forking To: Mateusz Guzik 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=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 Fri, Aug 4, 2023 at 6:17=E2=80=AFPM Mateusz Guzik wr= ote: > > 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 was just saying that vma lock patchset did not touch any other mmap_locking paths except for the page fault one where we try to skip read-locking mmap_lock. > > 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. :) Ok, I see. I'll need to double check locking when a 3rd party is involved. Will post a patch when I'm confident enough it's safe. Thanks! > > -- > Mateusz Guzik