From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 04C54606A6B5 for ; Sat, 5 Dec 2026 04:03:01 +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=Exs5lCYz Received: by kanga.kvack.org (Postfix) id 6C4E36B05C8; Fri, 4 Dec 2026 23:02:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 69D296B05CA; Fri, 4 Dec 2026 23:02:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5B2546B05CB; Fri, 4 Dec 2026 23:02:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D492D6B05C8 for ; Fri, 4 Dec 2026 23:02:54 -0500 (EST) Received: from smtpin04.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay09.hostedemail.com (Postfix) with ESMTP id ADACB8028C for ; Sat, 5 Dec 2026 04:02:52 +0000 (UTC) X-FDA: 85508583384.04.B2F1A22 Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf01.hostedemail.com (Postfix) with ESMTP id 1882440007 for ; Sat, 5 Dec 2026 04:02:50 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=Exs5lCYz; spf=pass (imf01.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796443371; b=Xa7WueM3+TS79wCqQkEZEVk78Q1d6127nTB+mUuv8CKvtbDgMwwNXrc9aO+llkBqI7LcKq Ul2bfVMfIK1iRF6LZl7+8R1ElJPnYLi7+9GIiHLC8TV81s6tbTcmvFmp/d4Eb8Sk2ddyMK 72pPLKZ38pUUflo+kile8EmRkBuuXBY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796443371; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=xNRkQJw12N+3S0jczW9kqGSMy0OMgUJTLix8jye5tEo=; b=hejxzb/UWxCKuvfaOvLNl/LKGRCGJjg12C3hsHHX52IEILuu8Qxdi0O7XdPwM+qCaweARo KJiGxGbIG0vmrgBJ+3ZN6GVCGtzWFC1oZQaxJPNT18i0O4UbNkatlLtiXF5rSqb08J96Lf sxqFXzO2XbwYVlcFMKgYQCAPlgGjgSI= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=Exs5lCYz; spf=pass (imf01.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id ADC5F61B0D; Sat, 5 Dec 2026 04:02:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5CDB31F0092B; Sat, 5 Dec 2026 04:02:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796443370; bh=xNRkQJw12N+3S0jczW9kqGSMy0OMgUJTLix8jye5tEo=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=Exs5lCYzgClgU40+Ja+hjJ2TEET7Uwe0mHrvGt1Ll093I9pTUXJkc3Vb3cL4bpmOn WWOfG3yA7Z9dwgaNVEM99gNZJ6+W7uWFKT5j6RzE+zCuWf1Mg4//2VUh5Hf7xEY5uA XOZhLgkHvXxJ4UT1BCDRm9moZIUBwCyw3PG1fDJ2AdE+qKAxpx0p/WXuu3pUz622YQ gHxeddBC0QKL/rDTmYeuvpQnj3tbN5ag5vhRe/hiCwplU0TS+cEx1Sl0ULrj1AO4LY 6JDGovP9Uyu1bbmMWbu7iUfbFaLaPAgVUU9YcE6Iu+iTIzqGZRcpv7nrNLs0P6T+Pk 7BXxhCI6tD0RA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [RFC PATCH v10 19/28] fs: Support FSCONFIG_SET_RUN in fsconfig() Reply-To: sashiko-reviews@lists.linux.dev To: "Jarkko Sakkinen" Cc: bpf@vger.kernel.org, linux-mm@kvack.org, linux-security-module@vger.kernel.org, "Aleksa Sarai" , "Alexander Mikhalitsyn" , "Alexander Viro" , "Alexei Starovoitov" , "Andrew Morton" , "Andrii Nakryiko" , "Andy Lutomirski" , "Arnd Bergmann" , "Baolin Wang" , "Ben Segall" , "Christian Brauner" , "Daniel Borkmann" , "David Hildenbrand" , "David Howells" , "David Woodhouse" , "Davidlohr Bueso" , "Dietmar Eggemann" , "Eduard Zingerman" , "Emil Tsalapatis" , "Eric Biggers" , "Georgia Garcia" , "Giuseppe Scrivano" , =?utf-8?b?R8O8bnRoZXIgTm9hY2s=?= , "Hugh Dickins" , "Ihor Solodrai" , "Ingo Molnar" , "James Morris" , "Jan Kara" , "Jason Gunthorpe" , "Jeff Layton" , "Jiri Olsa" , "John Johansen" , "Jonathan Corbet" , "Josef Bacik" , "Juri Lelli" , "Kees Cook" , "K Prateek Nayak" , "KP Singh" , "Kumar Kartikeya Dwivedi" , "Lennart Poettering" , "Liam R. Howlett" , "Manfred Spraul" , "Martin KaFai Lau" , "Matt Bobrowski" , "Mel Gorman" , "Michal Hocko" , =?utf-8?b?TWlja2HDq2wgU2FsYcO8bg==?= , "Mike Rapoport" , "Neal Gompa" , "Oleg Nesterov" , "Paul Moore" , "Pavel Tikhomirov" , "Peter Zijlstra" , "Randy Dunlap" , "Serge E. Hallyn" , "Serge Hallyn" , "Shuah Khan" , "Song Liu" , "Stephen Smalley" , "Steven Rostedt" , "Valentin Schneider" , "Vincent Guittot" , "Yonghong Song" , "Zygmunt Krynicki" In-Reply-To: <20261205032633.1702772-20-jarkko@kernel.org> References: <20261205032633.1702772-1-jarkko@kernel.org> <20261205032633.1702772-20-jarkko@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 04:02:46 +0000 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 1882440007 X-Rspam-User: X-Stat-Signature: qmmwefxjypyryb743kxwruasj9h6edcq X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-HE-Tag: 1796443370-838428 X-HE-Meta: U2FsdGVkX1+utsG0mp/aZ0ZiVFDErcWg9G1wk0HmNydCMNuxqm29pOFavOrU7Okfd7AyGAarU1ethyQxivRUuRrVVP27kY74emagXXkwRZJ3D1ES7h5gaHyQ6EgBkmwXS/tkqKTzYtp/SrFLFL+lRUtV8QxA6lPjXuU3g6MAgodP8wDeJw6d53UqkH2IUVNZubDV7eJ+bMkyH3pAmHC564Si0o1vphtjKSXgJ+yz3dRUwgvjrOSy7ZMjsY6m76CmYGOeKbBbczZvjEEmTB+x4L5typFfXKl2EMeYUG3yol4D/dX4FjfAks2C60GlOOrW960Hr1l8+vmuWgE2z6pIWCFdGL/tmimEn771ybygCtAV1VVuhFtblgr9OkNz8EVc9T874/0BgiobwQDECy7XeP5n/z9PGI2SDIUBfTRsw9M1PGk4b8CwlPKqq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mF7A7+mpq5sj+Re2fKMxvrGTZnQa2/O7LMm1M7PQ0GoOTnRPukUHmVr/j3ODNLvJC0xhBaXDfUN9lB6q7809jht8+ksxwDFpxGrXJL2XehTtp5NImx/jezPVid3zNbv9slbjjafyohFKlmBOYkEs3zwCJVwV+nbft7FjTWFpAHjKY3V/Bhl+VHPlNRfmdR+UvdJPLoumLOrZ4Zr8oxFhkZ4GCr/HWbOXpfkNMthuI9L2p9W3OVXHVptNTWRRpwPfKoEg7lQEQgSwPBikeKNDEHsj+UYaJk8LTYBfa1fAWu8BGw+FKIs+7IKYCYfc5V/zWfHTDIC4NHajth9+fASqF7Bh2R/URBzJc0EwtLvVLBrnHB+288picqWXOXh+PwNNfXTgwKZ6knaUwg== Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] fs: missing net_ns authorization check in fsconfig_set_run() - [Low] fs: undocumented locking contract for ->set_run() in mount_api.rst -- commit dc21c813c62c5e4df497ad5f2435f915174cf31b Author: Jarkko Sakkinen fs: Support FSCONFIG_SET_RUN in fsconfig() This commit adds the FSCONFIG_SET_RUN fsconfig() command, the ->set_run() fs_context operation, and the FS_RUN_MOUNT filesystem flag so callers with CAP_SYS_ADMIN in a run's user namespace can bind a new fs_context to that run's namespaces and create detached mounts for it. > diff --git a/Documentation/filesystems/mount_api.rst b/Documentation/file= systems/mount_api.rst > index e8b94357b4dff..3b597f727d23a 100644 > --- a/Documentation/filesystems/mount_api.rst > +++ b/Documentation/filesystems/mount_api.rst [ ... ] > @@ -272,6 +285,26 @@ manage the filesystem context. They are as follows: > finds it's the standard key-val list then it may pass it off to > generic_parse_monolithic(). > =20 > + * :: > + > + int (*set_run)(struct fs_context *fc, > + struct run *run); > + > + Called by FSCONFIG_SET_RUN after updating fc->user_ns, fc->net_ns, > + and fc->cred, setting fc->run_bound, and re-running > + ->init_fs_context(). Filesystems opting into FS_RUN_MOUNT (or > + FS_USERNS_DELEGATABLE) that capture additional namespaces from curr= ent in > + ->init_fs_context() (such as PID or IPC namespaces) can implement t= his > + operation to rebind their private context to the target run's > + namespaces. It may update fc->user_ns (for example to a shared > + namespace's owning user namespace), in which case the caller must h= old > + CAP_SYS_ADMIN in fc->user_ns or the bind fails with -EPERM. When > + ->set_run is NULL, fc->user_ns must equal run->user_ns after > + ->init_fs_context() or the bind fails with -EOPNOTSUPP. > + > + On success it should return 0. In the case of an error, it should = return > + a negative error code and the context transitions to FS_CONTEXT_FAI= LED. [Severity: Low] Should this document the locking contract for ->set_run()? fsconfig_set_run() calls ->set_run() in sleepable context under fc->uapi_mutex without run->lock held. Meanwhile, runfd_share_nsfd() replaces mutable pointers in run->ns (such as ipc_ns) under run->lock and drops the old reference immediately after unlocking. Documenting that callbacks must hold run->lock while taking a reference on replaceable namespaces would prevent future implementations from introducing a use-after-free. [ ... ] > diff --git a/fs/fsopen.c b/fs/fsopen.c > index 70024870fefa2..82351d6eabe0d 100644 > --- a/fs/fsopen.c > +++ b/fs/fsopen.c [ ... ] > @@ -41,6 +46,84 @@ static inline const char *fetch_message_locked(struct = fc_log *log, size_t len, [ ... ] > +static int fsconfig_set_run(struct fs_context *fc, struct fs_parameter *= param) > +{ > + struct user_namespace *user_ns; > + struct net *net; > + struct run *c; > + int ret; > + > + if (!runfd_is_file(param->file)) > + return -EINVAL; > + > + c =3D param->file->private_data; > + user_ns =3D c->user_ns; > + if (!ns_capable(user_ns, CAP_SYS_ADMIN)) > + return -EPERM; > + if (!(fc->fs_type->fs_flags & > + (FS_RUN_MOUNT | FS_USERNS_DELEGATABLE))) > + return -EOPNOTSUPP; [ ... ] > + scoped_guard(spinlock, &c->lock) > + net =3D get_net(c->ns->net_ns); > + put_cred(fc->cred); > + fc->cred =3D get_current_cred(); > + put_net(fc->net_ns); > + fc->net_ns =3D net; [Severity: Medium] Can this bind fc->net_ns to a shared network namespace the caller is not authorized to access? runfd_share_nsfd() allows replacing c->ns->net_ns with a foreign network namespace such as init_net, and runfd_check_namespaces() enforces runfd_may_use_ns() on net_ns when spawning into the run. Here, fsconfig_set_run() checks only ns_capable(c->user_ns, CAP_SYS_ADMIN). A task in an isolated net_ns with CAP_SYS_ADMIN in c->user_ns can open nfs (FS_USERNS_DELEGATABLE), bind fc->net_ns, and set addr to "fe80::1%". nfs_fs_context_parse_param() calls dev_get_by_name() on fc->net_ns before mount_capable(), probing interfaces in that net_ns. Checking net_eq(net, current->nsproxy->net_ns) || ns_capable(net->user_ns, CAP_SYS_ADMIN) on the captured net before mutating fc, and returning -EPERM with put_net(net) on failure, would match the runfd_may_use_ns() policy. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205032633.1702= 772-1-jarkko@kernel.org?part=3D19