public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bpf: use FS_USERNS_DELEGATABLE for bpffs
@ 2026-02-05 10:45 Alexander Mikhalitsyn
  2026-02-05 11:20 ` bot+bpf-ci
                   ` (5 more replies)
  0 siblings, 6 replies; 18+ messages in thread
From: Alexander Mikhalitsyn @ 2026-02-05 10:45 UTC (permalink / raw)
  To: ast
  Cc: Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau,
	Eduard Zingerman, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Jeff Layton,
	Christian Brauner, bpf, linux-fsdevel, linux-kernel,
	Alexander Mikhalitsyn

From: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@futurfusion.io>

Instead of FS_USERNS_MOUNT we should use recently introduced
FS_USERNS_DELEGATABLE cause it better expresses what we
really want to get there. Filesystem should not be allowed
to be mounted by an unprivileged user, but at the same time
we want to have sb->s_user_ns to point to the container's
user namespace, at the same time superblock can only
be created if capable(CAP_SYS_ADMIN) check is successful.

Tested and no regressions noticed.

No functional change intended.

Link: https://lore.kernel.org/linux-fsdevel/6dd181bf9f6371339a6c31f58f582a9aac3bc36a.camel@kernel.org [1]
Fixes: 6fe01d3cbb92 ("bpf: Add BPF token delegation mount options to BPF FS")
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: Martin KaFai Lau <martin.lau@linux.dev>
Cc: Eduard Zingerman <eddyz87@gmail.com>
Cc: Song Liu <song@kernel.org>
Cc: Yonghong Song <yonghong.song@linux.dev>
Cc: John Fastabend <john.fastabend@gmail.com>
Cc: KP Singh <kpsingh@kernel.org>
Cc: Stanislav Fomichev <sdf@fomichev.me>
Cc: Hao Luo <haoluo@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Jeff Layton <jlayton@kernel.org>
Cc: Christian Brauner <brauner@kernel.org>
Cc: bpf@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@futurfusion.io>
- RWB-tag from Jeff [1]
Reviewed-by: Jeff Layton <jlayton@kernel.org>
---
 kernel/bpf/inode.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
index 9f866a010dad..d8dfdc846bd0 100644
--- a/kernel/bpf/inode.c
+++ b/kernel/bpf/inode.c
@@ -1009,10 +1009,6 @@ static int bpf_fill_super(struct super_block *sb, struct fs_context *fc)
 	struct inode *inode;
 	int ret;
 
-	/* Mounting an instance of BPF FS requires privileges */
-	if (fc->user_ns != &init_user_ns && !capable(CAP_SYS_ADMIN))
-		return -EPERM;
-
 	ret = simple_fill_super(sb, BPF_FS_MAGIC, bpf_rfiles);
 	if (ret)
 		return ret;
@@ -1085,7 +1081,7 @@ static struct file_system_type bpf_fs_type = {
 	.init_fs_context = bpf_init_fs_context,
 	.parameters	= bpf_fs_parameters,
 	.kill_sb	= bpf_kill_super,
-	.fs_flags	= FS_USERNS_MOUNT,
+	.fs_flags	= FS_USERNS_DELEGATABLE,
 };
 
 static int __init bpf_init(void)
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2026-02-09 11:11 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-05 10:45 [PATCH] bpf: use FS_USERNS_DELEGATABLE for bpffs Alexander Mikhalitsyn
2026-02-05 11:20 ` bot+bpf-ci
2026-02-05 11:27   ` Alexander Mikhalitsyn
2026-02-05 12:38     ` Daniel Borkmann
2026-02-05 12:49       ` Alexander Mikhalitsyn
2026-02-05 13:57         ` Alexander Mikhalitsyn
2026-02-05 16:43     ` Alexei Starovoitov
2026-02-05 17:17       ` Alexander Mikhalitsyn
2026-02-05 17:24         ` Alexei Starovoitov
2026-02-05 17:58 ` kernel test robot
2026-02-05 21:06 ` kernel test robot
2026-02-05 21:43 ` kernel test robot
2026-02-05 22:58 ` kernel test robot
2026-02-06 12:32 ` Christian Brauner
2026-02-06 12:42   ` Alexander Mikhalitsyn
2026-02-06 12:44     ` Alexander Mikhalitsyn
2026-02-09 11:11     ` Christian Brauner
2026-02-06 12:45   ` Jeff Layton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox