Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2534219rdh; Sun, 29 Oct 2023 22:46:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFq7eWOKJBjkUsHM5gTOL3jflB1dGNvqioXAHC92QBJ/XHBP0+pivNAx+y5Os+it+Xd1+gk X-Received: by 2002:a17:902:d2c7:b0:1cc:4efc:c87d with SMTP id n7-20020a170902d2c700b001cc4efcc87dmr1319303plc.55.1698644789664; Sun, 29 Oct 2023 22:46:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698644789; cv=none; d=google.com; s=arc-20160816; b=ujpy4D7QcsxUhLuD+bZ3CtSwS5nMyzN6hkizvdhDtpwzba836pVLMWwX7Y9iWe+EJc mWHLz+l/ZS/+eSLtHkgWfx3e/Og/Wm/zZoZa126+XBDPApg0KezaYzwf0q6xS67ghaj1 0KktCBEGNFo/NPxaQRw+YoNUbZGtgs6lVBJAojrMMbqEiH1qHxxVBIE0tVYYdLgZO68t XqCgP+bjW4Z2gEaHou5jTMTlNsfCqHjV0zpY928U72ul/MVWkGDCWQjdZoWhwwH/3vb0 26tfg9xeoWQQvj3UR84uXHmKuajv7hmWMMo6EQtSfDqEGcOLnkukUWvxbCmC6c7CKqIC 67hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:feedback-id:dkim-signature:dkim-signature; bh=jaTWG66pDHoMbCEBoC0gkbfu5n/wvjRGKKr6RONugiw=; fh=0aClYxBEUJjF5QzWPOIwz0LsBVX1cvMGrZ1POdvkB/o=; b=xuZLtjwWO6Mq+hHH0ndGzCN+4JN/khctbNr3WawJ8Z/npsQS1iqTzPgRexU5x4qTFT 9wBv2qhLaB9sUKPFXvygw90nYVnpwuYdasXwOZh5+fZ/3iw69ovJ9Z1FwDy59xTWiwDA sqDo01YVX+Yrs3Qc5W0XhNgxM25DnURO+aoJvMXT4fD5xyephI8hzvpBh3Qen/kOAeW1 OY3sM+w45+6px+AVuzgKdootuxCcwDRpiovL7LeXtRtkeU4UN3kVHmrF3jTMtF9DuS5W ESdj7Pei0G5z1byIkzJ2wV1WagWAd6n7hcQHyffu3qqTvYWUK02tU8mQ9ULTGVWzjwz4 7BBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@themaw.net header.s=fm2 header.b=kH1PljIw; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b="lU/j/+Gs"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id i9-20020a170902c94900b001bb9375b349si4763065pla.536.2023.10.29.22.46.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Oct 2023 22:46:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@themaw.net header.s=fm2 header.b=kH1PljIw; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b="lU/j/+Gs"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 7685480781F1; Sun, 29 Oct 2023 22:45:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231189AbjJ3Fpr (ORCPT + 99 others); Mon, 30 Oct 2023 01:45:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229829AbjJ3Fpq (ORCPT ); Mon, 30 Oct 2023 01:45:46 -0400 Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C00D9BC; Sun, 29 Oct 2023 22:45:43 -0700 (PDT) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id 01D4C3200988; Mon, 30 Oct 2023 01:45:41 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Mon, 30 Oct 2023 01:45:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=themaw.net; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1698644741; x=1698731141; bh=jaTWG66pDHoMbCEBoC0gkbfu5n/wvjRGKKr 6RONugiw=; b=kH1PljIwB4mx8xnaIGjwZChPF+ytCawKcocvOonU1W80TSZWp7A mlndkyy1y+v/Pp5M1Ti83zkcRGcpZEX8qlYgTYvlWUISmO7ywFth8lvMO1TOM1PW ESUBADIRp9beHdJ5/jRCsesd1tHJIl9C2+xvZtsLgEH51g1M0AsnI0UsqfBb+9rM 46Cyet41GCFc5y01IQJpT62gHDNEp8coBIY66tx86nQbOxtedlnqHFoWxaKYsW6M 7NBSWFS4kgLFziprja2mK1e0I7mfD/w5NfmRN7XI1jp93GE1UVTgUeG3BLSn5Pvd s9F8Tx74suf3yQcN4y6tEb9ZiVtxjAaLvVQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1698644741; x=1698731141; bh=jaTWG66pDHoMbCEBoC0gkbfu5n/wvjRGKKr 6RONugiw=; b=lU/j/+GsBZjBEEfDrgUzeheIxy92PUsVQwlz9VpHBPNkyGeJuEp Ie4cXb1MwbbxAZXN8YU+ms/igcfooRHZBD/kJqX3qsI3j4GlAs4O6qv8qVOqO9Jf Q7AecRB79YnnBiICaFAAmthF6J1Hs3YGSG3DTxQZtOaAWsGTnI/fdiO2Xjr1wLc8 ASaFSONgTCewvWzr2QWqnM1/6YTeGbWt1AaNniaLvZr6NF3BE5EpiDfxGO3XArfY n6vYrs47fmcxnPdnwueK8nerYpL3BgGYFf6euhUHPZFk6Fu0FSaI8Z09EG6Tqiqv Q+Roqn/VyaZwP+74u0rJyQfLkxDneCowbRw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrleelgdekkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefkffggfgfuhffvvehfjggtgfesthekredttdefjeenucfhrhhomhepkfgrnhcu mfgvnhhtuceorhgrvhgvnhesthhhvghmrgifrdhnvghtqeenucggtffrrghtthgvrhhnpe eiveelkefgtdegudefudeftdelteejtedvheeuleevvdeluefhuddtieegveelkeenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrrghvvghnse hthhgvmhgrfidrnhgvth X-ME-Proxy: Feedback-ID: i31e841b0:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 30 Oct 2023 01:45:35 -0400 (EDT) Message-ID: Date: Mon, 30 Oct 2023 13:45:33 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v4 2/6] mounts: keep list of mounts in an rbtree Content-Language: en-US From: Ian Kent To: Miklos Szeredi Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, linux-man@vger.kernel.org, linux-security-module@vger.kernel.org, Karel Zak , David Howells , Linus Torvalds , Al Viro , Christian Brauner , Amir Goldstein , Matthew House , Florian Weimer , Arnd Bergmann References: <20231025140205.3586473-1-mszeredi@redhat.com> <20231025140205.3586473-3-mszeredi@redhat.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sun, 29 Oct 2023 22:45:59 -0700 (PDT) On 30/10/23 13:37, Ian Kent wrote: > On 28/10/23 09:36, Ian Kent wrote: >> On 27/10/23 16:17, Miklos Szeredi wrote: >>> On Fri, Oct 27, 2023 at 5:12 AM Ian Kent wrote: >>>> On 25/10/23 22:02, Miklos Szeredi wrote: >>>>> The mnt.mnt_list is still used to set up the mount tree and for >>>>> propagation, but not after the mount has been added to a >>>>> namespace.  Hence >>>>> mnt_list can live in union with rb_node.  Use MNT_ONRB mount flag to >>>>> validate that the mount is on the correct list. >>>> Is that accurate, propagation occurs at mount and also at umount. >>> When propagating a mount, the new mount's mnt_list is used as a head >>> for the new propagated mounts.  These are then moved to the rb tree by >>> commit_tree(). >>> >>> When umounting there's a "to umount" list called tmp_list in >>> umount_tree(), this list is used to collect direct umounts and then >>> propagated umounts.  The direct umounts are added in umount_tree(), >>> the propagated ones umount_one(). >>> >>> Note: umount_tree() can be called on a not yet finished mount, in that >>> case the mounts are still on mnt_list, so umount_tree() needs to deal >>> with both. >>> >>>> IDG how the change to umount_one() works, it looks like umount_list() >>>> >>>> uses mnt_list. It looks like propagate_umount() is also using >>>> mnt_list. >>>> >>>> >>>> Am I missing something obvious? >>> So when a mount is part of a namespace (either anonymous or not) it is >>> on the rb tree, when not then it can temporarily be on mnt_list. >>> MNT_ONRB flag is used to validate that the mount is on the list that >>> we expect it to be on, but also to detect the case of the mount setup >>> being aborted. >>> >>> We could handle the second case differently, since we should be able >>> to tell when we are removing the mount from a namespace and when we >>> are aborting a mount, but this was the least invasive way to do this. >> >> Thanks for the explanation, what you've said is essentially what I >> >> understood reading the series. >> >> >> But I still haven't quite got this so I'll need to spend more time >> >> on this part of the patch series. >> >> >> That's not a problem, ;). > > After cloning your git tree and looking in there I don't see what > > I was concerned about so I think I was confused by obscurity by > > diff rather than seeing a real problem, ;) > > > Still that union worries me a little bit so I'll keep looking at > > the code for a while. Is fs/namespace.c:iterate_mounts() a problem? It's called from: 1) ./kernel/audit_tree.c:709: if (iterate_mounts(compare_root, 2) ./kernel/audit_tree.c:839:    err = iterate_mounts(tag_mount, tree, mnt); 3) ./kernel/audit_tree.c:917:        failed = iterate_mounts(tag_mount, tree, tagged); From functions 1) audit_trim_trees(), 2) audit_add_tree_rule() and 3) audit_tag_tree(). > > >> >> >> Ian >> >>> >>> Thanks, >>> Miklos >>> >> >