* [PATCH bpf-next] bpf: use FS_USERNS_DELEGATABLE for bpffs
@ 2026-11-03 10:14 Alexander Mikhalitsyn
0 siblings, 0 replies; only message in thread
From: Alexander Mikhalitsyn @ 2026-11-03 10:14 UTC (permalink / raw)
To: ast
Cc: brauner, jlayton, Alexander Mikhalitsyn, Daniel Borkmann,
Andrii Nakryiko, Eduard Zingerman, Kumar Kartikeya Dwivedi,
Martin KaFai Lau, Song Liu, Yonghong Song, Jiri Olsa,
Emil Tsalapatis, Ihor Solodrai, bpf, linux-kernel
Instead of FS_USERNS_MOUNT we should use recently introduced [1]
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 should be allowed
be created only if capable(CAP_SYS_ADMIN) check is successful.
Tested and no regressions noticed.
No functional change intended.
Link: https://lore.kernel.org/all/20260129-twmount-v1-1-4874ed2a15c4@kernel.org/ [1]
Signed-off-by: Alexander Mikhalitsyn <alex@amutable.com>
---
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 c6f328e4752e..e8ec41f095fd 100644
--- a/kernel/bpf/inode.c
+++ b/kernel/bpf/inode.c
@@ -1188,10 +1188,6 @@ static int bpf_fill_super(struct super_block *sb, struct fs_context *fc)
struct bpf_mount_opts *opts = sb->s_fs_info;
struct inode *inode;
- /* Mounting an instance of BPF FS requires privileges */
- if (fc->user_ns != &init_user_ns && !capable(CAP_SYS_ADMIN))
- return -EPERM;
-
sb->s_blocksize = PAGE_SIZE;
sb->s_blocksize_bits = PAGE_SHIFT;
sb->s_magic = BPF_FS_MAGIC;
@@ -1280,7 +1276,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 void bpf_fs_inode_init_once(void *foo)
--
2.47.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-03 10:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-03 10:14 [PATCH bpf-next] bpf: use FS_USERNS_DELEGATABLE for bpffs Alexander Mikhalitsyn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®