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=1796443370; b=sGppi+XEgfB0j0T+kAcG7x5nrBwL0NXshAV25TJSdueiAL8D6m3r7SjrAUaSPLDdSez0 XrEf0jSZmWueGURiOfG9U33/mrM0KFlStI3MAtbzNkKTuYYb93DQkiTC1b0gSXkcjf0uc KrdZYwbZa6duNsTaxIR6LgicgXWz0z40QuwTPRAICfFml8rRBGYSCrYhsfynGVlzHQuQv qcTHDjN6uwjVFIJRyyXc8iACPRQ2O9tMZCkZ8bXeEhXn+0YcuZzSiKbOuzWnRdHpLSaVa +lNA180ykio0fsY942l+LKKZjFqusFL0WdjHd/rBU4ZVOBpft9UeqWBSx7i4NKgLx7g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796443370; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=xNRkQJw12N+3S0jczW9kqGSMy0OMgUJTLix8jye5tEo=; b=MFwPjhtKUMvHIk9OfY2mafqOM18EyEwKacLJ6mrn87wZrJEBm1nHUjDZTF+H3eYnAbip anjy45K1ffPCzX5vVJ1gQXp0zvfOyFkDAaMM8KZTXk/ADYT43lx171eepksAu5v0QTy8m 7N/mLU4f5yPBzWuAz33/C2KSydOM+bskE0q2EmMdQ1KH62Z/PV2Ees+kML2xRPAGuFfJo hbIc6yUZnNYBM+s/KiG0opmrchtQD9/Qx+7MnjM253pZqi5b3RyLvMEp8DH0A5G8W08Hz T6a9pQqg/ZCEeSbAsPVdM8BiP4jnl8DMnbCyfJmSo7MCiGT9+4u/7h3yIvr2PgUffXQ== 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=Exs5lCYz; 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 ESMTPS id 8BDFD606A33B; Sat, 5 Dec 2026 04:02:50 +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 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-Mailing-List: linux-security-module@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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