From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795178824; b=Jty6fYz9Mg4FslCKe8/nES5UnhFW1PHMt/cfJk6csa5uegc+vQlzUM+4ZXOarKJYod2/ 1dXxeDp/CmRlHyBCpRHqdSK6XqhILGHLjp65e9TbFo0wjdUORP++NO3enFlmmM7F3SQOr WXzdhrwik7M0/dL7tmtzaC4UkXnp1J3QTIcJ7ymcc0TxIi+3F5xZ7PMAARE8YhUHuZmCz 3fk5ceR7QtQpzcr+xIi8kfrpVenCR1k60deXHHVCPA0XeXDIQvIEX8If4HrytqfmnnpWB tDdjrtfnr+Qw4V/yudFCM4RldNeopFkocWIbYITXYYxvGcyU+g25TAzLxNdWqUgbXVg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795178824; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=0ulF/F82puM5FYsSJ0g59/1wc8Edn/NytcDM7FiJ8jc=; b=v0wNUqJK8koC0NnRS5+W3RMN7uRLuM/kwo2Rr+dkq4ySkGOhjdT1wREeBChwTRTf4Pc4 gP1yCbbu0fGupTRrNZ83ndwO+EleldJL+tjJzRROSH8KAffCIjf+S+1yN0bVDwRwo0TlW is/xnRRuytpQ7ouddnQRuMrvzmY0PeFjPFIOejxBdCJ+h5wbAsCDdyU91MJQg0R70GETQ idxqWJg7jPr3lNloKrCiJniI+TASZXFzOVOxZxXG1tIW5mUb2f7BxuTUYza7vsWhNhgqy kLtxKeynidRn0rwbx19AGaZPbavOdCBbw3x5yMZqSGqdji+DJDz4zMgOeEAw4ZkY/+w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=DqoZLySG; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with UTF8SMTPS id 879F660A2607; Fri, 20 Nov 2026 12:47:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=DqoZLySG Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id 1F3B61F01816; Fri, 20 Nov 2026 12:47:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795178823; bh=0ulF/F82puM5FYsSJ0g59/1wc8Edn/NytcDM7FiJ8jc=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=DqoZLySG6tbEny6oIUE/axFh/2wx4W5GHzOkvhTlgcaY4EZUTlRys71s81y3ij2s+ Rx6evb1/Oa+v4+RmHdPnlMI8p3/9Vk2Qlijco1EtXlIo6+Uox0MEXkH/j5p22LtJG8 O+pAzJgjaL1XHgOBkbBGKjTQJ9BhUBlib22F8c7LUzIeRP0B3hW1yyMckmXfB09V3/ pb0B13DLnURH0RN2WYu1RtEzVFvz+D8QM0Yu59J9hZtbKvXjbGvXTuwegQcAfBSTXZ ryU1OkE2JtMJpTX6AEDJ3anQ8K5ylpOqcKArjol4ky4NYsELzEC9Sl23cE4WQ60q2T OvpwQRIevpNOw== Date: Fri, 20 Nov 2026 14:47:00 +0200 From: Jarkko Sakkinen To: linux-fsdevel@vger.kernel.org Cc: linux-api@vger.kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, linux-security-module@vger.kernel.org, Albert Ou , Alexander Gordeev , Alexander Viro , Alexandre Ghiti , Andreas Larsson , Andrew Morton , Andy Lutomirski , Andy Lutomirski , Anna-Maria Behnsen , Arnd Bergmann , Ben Segall , Borislav Petkov , Casey Schaufler , Catalin Marinas , Christian Borntraeger , Christian Brauner , "Christophe Leroy (CS GROUP)" , Chris Zankel , Dave Hansen , David Hildenbrand , David Howells , Davidlohr Bueso , "David S. Miller" , Dietmar Eggemann , Frederic Weisbecker , Geert Uytterhoeven , "Hallgrimur H. Gunnarsson" , Heiko Carstens , Helge Deller , "H. Peter Anvin" , Ingo Molnar , "James E.J. Bottomley" , Jan Kara , John Johansen , John Paul Adrian Glaubitz , Jonathan Corbet , Josef Bacik , Juri Lelli , Kees Cook , K Prateek Nayak , "Liam R. Howlett" , Lorenzo Stoakes , Madhavan Srinivasan , Magnus Lindholm , Manfred Spraul , Mark Rutland , Matt Turner , Max Filippov , Mel Gorman , Michael Ellerman , Michal Hocko , Michal Simek , Mike Rapoport , Neal Gompa , Nicholas Piggin , Palmer Dabbelt , Paul Moore , Paul Walmsley , Pavel Tikhomirov , Peter Zijlstra , Randy Dunlap , Richard Henderson , Rich Felker , "Ritesh Harjani (IBM)" , Russell King , Serge Hallyn , Shrikanth Hegde , Shuah Khan , Steven Rostedt , Suren Baghdasaryan , Sven Schnelle , Thomas Bogendoerfer , Thomas Gleixner , Valentin Schneider , Vasily Gorbik , Vincent Guittot , Vincenzo Frascino , Vlastimil Babka , Will Deacon , Yoshinori Sato , Zygmunt Krynicki Subject: Re: [RFC PATCH v4 07/14] fork: Support CLONE_INTO_ROOTNS in clone3() Message-ID: References: <20261119224312.1037966-1-jarkko@kernel.org> <20261119224312.1037966-8-jarkko@kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Fri, Nov 20, 2026 at 12:33:25PM +0200, Jarkko Sakkinen wrote: > On Fri, Nov 20, 2026 at 12:43:05AM +0200, Jarkko Sakkinen wrote: > > Multithreaded userspace daemons cannot call setns(CLONE_NEWUSER) or > > safely mutate process-wide filesystem state in place before spawning a > > child into a target namespace set. > > > > Add CLONE_INTO_ROOTNS and struct clone_args.rootns (CLONE_ARGS_SIZE_VER3) > > to spawn a child process directly into a rootns whose root mount has > > been installed. Transition the rootns from ROOTNS_INIT through > > ROOTNS_FORKING to ROOTNS_RUNNING for the first process so it becomes > > PID 1, serialize concurrent entrants on waitq until bootstrap resolves, > > and admit subsequent callers into the running PID namespace until > > teardown begins. > > > > Derive child credentials from current, require CAP_SYS_ADMIN and > > CAP_SYS_CHROOT in the target user namespace and an ancestor active PID > > namespace, preserve caller umask, reset dumpability across user namespace > > transitions, commit time namespace vvar mappings after copy_process() > > succeeds, and look up the live mount namespace root. Restrict companion > > flags to CLONE_VFORK, CLONE_PIDFD, CLONE_PIDFD_AUTOKILL, CLONE_AUTOREAP, > > CLONE_CLEAR_SIGHAND, CLONE_INTO_CGROUP, and CLONE_NNP. > > > > Co-developed-by: David Howells > > Signed-off-by: David Howells > > Signed-off-by: Jarkko Sakkinen > > Being fd-bound object the gist is that the first clone3() binds > cgroups, which could e.g., different process than who build the > container. > > CLONE_INTO_CGROUPS is of course available as an optional flag when > using CLONE_INTO_ROOTNS. The major benefit over Cells is that there is no embryonic task state and nothing from the host mount table is inherited unless explicitly moved in. Also, unshare() cannot ascend from the rootns() created hierarchy. Shooting yourself in the foot is an explicit and planned action taken. And further, it has provably more defence in depth than Cells because LSM hooks accurately populate the data crossings. Br, Jarkko