Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp972253pxu; Mon, 23 Nov 2020 08:33:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJwPCVECfnq+4x26U0kZnr2iqMfWTmey/eCznx3XBwx5myqV//YzSIzZYTj8tFejHP7NQlqb X-Received: by 2002:a17:906:831a:: with SMTP id j26mr407470ejx.450.1606149199979; Mon, 23 Nov 2020 08:33:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606149199; cv=none; d=google.com; s=arc-20160816; b=hAUgqz/zluoISmF06QX/Bxuiy6c8aiGPxhdQg9oFS14iFys/h0heGWrdn0Mr8PCbab JrmsVAvaaG3Bi06y2YWUQHpErXzR9QBJrUpMyQZNkTkYRLpWnKkmyyVlHkuT+uW1/Hlb AnQfmVxSeQGNVi//MS/soG04GyG7FrNWcVBeyc28CB/TSbKW+Jr6k0fH79DKOP35YtUv YU5RO+Lew2DvqZZXih0Huj44wmF16UmQzSy5n/BauZJJ0gSAH3WadCsLw78QckH4nQm8 GuP2YxEhxVMQ2/ksC2fULvoorB5OlYKBR4WyFP99jWnp3Uml8LRJ4CDOGIgEhC5cPTAN oB+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=dCNTwpbrygdlSzzc2FSEUktQs4G/tw8OZWUghu6D3ME=; b=WDg+iySeVL4qIvcPZjZHDXr8O4kzB8pWs+fLocpOH143E0hJayYsALqmv+TMQpPCq7 BEev39Bx6fY0V67tJhL+DxYmFB6Q2oPJwJcWgCnsQrAevl39vfG9izFPC9WgUnpH8gDN kDATR92mraUtFkkesOJwhrRk2d2nN3ygn1z31vcGACm5vObdjR7bUiw7/yy+a32wf8QF p39ff0A6kQSEPKfba/1iQGrucHLO9k9i1n9RPvwW1wsGymh97F09ogml2hKOrwmJi81r 1jHYvUQ+4iv8Ku+5EPE0bnNPDyeE2L7UbjXp783/Go8hW8kcXRyNL8AZo/JrG8xdYaM2 kz+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tycho.pizza header.s=fm1 header.b=mvdckROr; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=ApOjkzVh; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z15si2530172eji.718.2020.11.23.08.32.54; Mon, 23 Nov 2020 08:33:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@tycho.pizza header.s=fm1 header.b=mvdckROr; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=ApOjkzVh; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729294AbgKWQbe (ORCPT + 99 others); Mon, 23 Nov 2020 11:31:34 -0500 Received: from new4-smtp.messagingengine.com ([66.111.4.230]:48269 "EHLO new4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730953AbgKWQZc (ORCPT ); Mon, 23 Nov 2020 11:25:32 -0500 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.nyi.internal (Postfix) with ESMTP id 74EC3580370; Mon, 23 Nov 2020 11:24:39 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Mon, 23 Nov 2020 11:24:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tycho.pizza; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=dCNTwpbrygdlSzzc2FSEUktQs4G /tw8OZWUghu6D3ME=; b=mvdckROrTihded/w+9kbPJNVEi2oJxpsRMBdE13AueF cwuXhp7Z5s5KniXQa1DndY9EPlaQ/d+ogqLn9NGqNE2FE+kWQsD3euvCwsXoTBpP USZ80C2yJENk16vx6Z8MC7CQCKCEdRubyZ6tEy+777bHg7UrRf0xedXg983fDZ/6 MaLCVcqHB+IWEeO+Qsyz0Uh0vGjKXLrSrtxFjX9oZ/xGJyvd19EoeHXG6WRgD+0A G7sHoeCQWvU2b5C3FOsujWiwg+cNqTPduzJqxAmcFfjCLx1tki5qvQlMV+zgsqZQ LGY2MNjuc7pqYwmKhNfumxsz7ybtxtyNBy4d4QHxUPw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=dCNTwp brygdlSzzc2FSEUktQs4G/tw8OZWUghu6D3ME=; b=ApOjkzVhfFeqlzdsO7tG0b x2bQvq7ntcNEhFM0AFLCrw3ZO/EH2RGTygVpMrJ3dAP6MlKHkmTa+uP0MyrFtomH 5LAjlgtNQN09OTRea7p7pYONwGQAiVwp9Ax0WCv7exAeYjgFHgcAeCCe86kOOEBw TxHIO8klW2S3Akyz3KykNiHdz1QbGkoVKP3HuUC5FxziM2P5ni1OV5BfU8lV8saq 2exDpozvp/Vgs0QTp5yJ7jm0oWt1ATsc/kFQ/EA/1DeayhNK2QO/GADZBALtBfgQ pLJfM2SFh/XPPgSNRfFT5zUu4QQ+7nTbkavi+lKMIQZrLlCIK7q6VOh5Ds2FvUrw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudegiedgledtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpefvhigthhho ucetnhguvghrshgvnhcuoehthigthhhosehthigthhhordhpihiiiigrqeenucggtffrrg htthgvrhhnpeegkeefjeegkedtjefgfeduleekueetjeeghffhuefgffefleehgeeifedv gfethfenucfkphepuddvkedruddtjedrvdeguddrudejgeenucevlhhushhtvghrufhiii gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehthigthhhosehthigthhhordhpihii iigr X-ME-Proxy: Received: from cisco (unknown [128.107.241.174]) by mail.messagingengine.com (Postfix) with ESMTPA id 652D83280060; Mon, 23 Nov 2020 11:24:30 -0500 (EST) Date: Mon, 23 Nov 2020 11:24:28 -0500 From: Tycho Andersen To: Christian Brauner Cc: Andy Lutomirski , Mimi Zohar , James Bottomley , Andreas Dilger , Christoph Hellwig , Jonathan Corbet , smbarber@chromium.org, Christoph Hellwig , Casey Schaufler , linux-ext4@vger.kernel.org, Mrunal Patel , Kees Cook , Arnd Bergmann , Jann Horn , selinux@vger.kernel.org, Josh Triplett , Seth Forshee , Aleksa Sarai , Alexander Viro , Lennart Poettering , OGAWA Hirofumi , Geoffrey Thomas , David Howells , John Johansen , Theodore Tso , Dmitry Kasatkin , containers@lists.linux-foundation.org, linux-security-module@vger.kernel.org, linux-audit@redhat.com, "Eric W. Biederman" , linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org, Alban Crequy , linux-integrity@vger.kernel.org, Stephen Smalley , Todd Kjos Subject: Re: [PATCH v2 07/39] mount: attach mappings to mounts Message-ID: <20201123162428.GA24807@cisco> References: <20201115103718.298186-1-christian.brauner@ubuntu.com> <20201115103718.298186-8-christian.brauner@ubuntu.com> <20201123154719.GD4025434@cisco> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201123154719.GD4025434@cisco> Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Mon, Nov 23, 2020 at 10:47:19AM -0500, Tycho Andersen wrote: > On Sun, Nov 15, 2020 at 11:36:46AM +0100, Christian Brauner wrote: > > +static inline struct user_namespace *mnt_user_ns(const struct vfsmount *mnt) > > +{ > > + return mnt->mnt_user_ns; > > +} > > I think you might want a READ_ONCE() here. Right now it seems ok, since the > mnt_user_ns can't change, but if we ever allow it to change (and I see you have > a idmapped_mounts_wip_v2_allow_to_change_idmapping branch on your public tree > :D), the pattern of, > > user_ns = mnt_user_ns(path->mnt); > if (mnt_idmapped(path->mnt)) { > uid = kuid_from_mnt(user_ns, uid); > gid = kgid_from_mnt(user_ns, gid); > } > > could race. Actually, isn't a race possible now? kuid_from_mnt(mnt_user_ns(path->mnt) /* &init_user_ns */); WRITE_ONCE(mnt->mnt.mnt_user_ns, user_ns); WRITE_ONCE(m->mnt.mnt_flags, flags); kgid_from_mnt(mnt_user_ns(path->mnt) /* the right user ns */); So maybe it should be: if (mnt_idmapped(path->mnt)) { barrier(); user_ns = mnt_user_ns(path->mnt); uid = kuid_from_mnt(user_ns, uid); gid = kgid_from_mnt(user_ns, gid); } since there's no data dependency between mnt_idmapped() and mnt_user_ns()? Tycho