History

fuse: allow idmapped mounts

Now we have everything in place and we can allow idmapped mounts by setting the FS_ALLOW_IDMAP flag. Notice that real availability of idmapped mounts will depend on the fuse daemon. Fuse daemon have to set FUSE_ALLOW_IDMAP flag in the FUSE_INIT reply. To discuss: - we enable idmapped mounts support only if "default_permissions" mode is enabled, because otherwise we would need to deal with UID/GID mappings in the userspace side OR provide the userspace with idmapped req->in.h.uid/req->in.h.gid values which is not something that we probably want to. Idmapped mounts philosophy is not about faking caller uid/gid. Some extra links and examples: - libfuse support https://github.com/mihalicyn/libfuse/commits/idmap_support - fuse-overlayfs support: https://github.com/mihalicyn/fuse-overlayfs/commits/idmap_support - cephfs-fuse conversion example https://github.com/mihalicyn/ceph/commits/fuse_idmap - glusterfs conversion example https://github.com/mihalicyn/glusterfs/commits/fuse_idmap

Alexander Mikhalitsyn committed 2 years ago

Commit 16e15031 parent 6d14b182 files · +28 −4Browse files

Unified · Split

2 files
  1. fs/fuse/inode.c +9 −3
  2. include/uapi/linux/fuse.h +19 −1
fs/fuse/inode.c+9−3
@@ -1348,6 +1348,12 @@ static void process_init_reply(struct fuse_mount *fm, struct fuse_args *args, · 1347 unmodified lines
13481348 }
13491349 if (flags & FUSE_NO_EXPORT_SUPPORT)
13501350 fm->sb->s_export_op = &fuse_export_fid_operations;
1351+ if (flags & FUSE_ALLOW_IDMAP) {
1352+ if (fc->default_permissions)
1353+ fm->sb->s_iflags &= ~SB_I_NOIDMAP;
1354+ else
1355+ ok = false;
1356+ }
13511357 } else {
13521358 ra_pages = fc->max_read / PAGE_SIZE;
13531359 fc->no_lock = 1;
@@ -1395,7 +1401,7 @@ void fuse_send_init(struct fuse_mount *fm) · 41 unmodified lines
13951401 FUSE_HANDLE_KILLPRIV_V2 | FUSE_SETXATTR_EXT | FUSE_INIT_EXT |
13961402 FUSE_SECURITY_CTX | FUSE_CREATE_SUPP_GROUP |
13971403 FUSE_HAS_EXPIRE_ONLY | FUSE_DIRECT_IO_ALLOW_MMAP |
1398− FUSE_NO_EXPORT_SUPPORT | FUSE_HAS_RESEND;
1404+ FUSE_NO_EXPORT_SUPPORT | FUSE_HAS_RESEND | FUSE_ALLOW_IDMAP;
13991405 #ifdef CONFIG_FUSE_DAX
14001406 if (fm->fc->dax)
14011407 flags |= FUSE_MAP_ALIGNMENT;
@@ -1985,7 +1991,7 @@ static void fuse_kill_sb_anon(struct super_block *sb) · 583 unmodified lines
19851991 static struct file_system_type fuse_fs_type = {
19861992 .owner = THIS_MODULE,
19871993 .name = "fuse",
1988− .fs_flags = FS_HAS_SUBTYPE | FS_USERNS_MOUNT,
1994+ .fs_flags = FS_HAS_SUBTYPE | FS_USERNS_MOUNT | FS_ALLOW_IDMAP,
19891995 .init_fs_context = fuse_init_fs_context,
19901996 .parameters = fuse_fs_parameters,
19911997 .kill_sb = fuse_kill_sb_anon,
@@ -2006,7 +2012,7 @@ static struct file_system_type fuseblk_fs_type = { · 14 unmodified lines
20062012 .init_fs_context = fuse_init_fs_context,
20072013 .parameters = fuse_fs_parameters,
20082014 .kill_sb = fuse_kill_sb_blk,
2009− .fs_flags = FS_REQUIRES_DEV | FS_HAS_SUBTYPE,
2015+ .fs_flags = FS_REQUIRES_DEV | FS_HAS_SUBTYPE | FS_ALLOW_IDMAP,
20102016 };
20112017 MODULE_ALIAS_FS("fuseblk");
20122018
include/uapi/linux/fuse.h+19−1
@@ -217,6 +217,9 @@ · 216 unmodified lines
217217 * - add backing_id to fuse_open_out, add FOPEN_PASSTHROUGH open flag
218218 * - add FUSE_NO_EXPORT_SUPPORT init flag
219219 * - add FUSE_NOTIFY_RESEND, add FUSE_HAS_RESEND init flag
220+ *
221+ * 7.41
222+ * - add FUSE_ALLOW_IDMAP
220223 */
221224
222225 #ifndef _LINUX_FUSE_H
@@ -252,7 +255,7 @@ · 29 unmodified lines
252255 #define FUSE_KERNEL_VERSION 7
253256
254257 /** Minor version number of this interface */
255−#define FUSE_KERNEL_MINOR_VERSION 40
258+#define FUSE_KERNEL_MINOR_VERSION 41
256259
257260 /** The node ID of the root inode */
258261 #define FUSE_ROOT_ID 1
@@ -421,6 +424,7 @@ struct fuse_file_lock { · 162 unmodified lines
421424 * FUSE_NO_EXPORT_SUPPORT: explicitly disable export support
422425 * FUSE_HAS_RESEND: kernel supports resending pending requests, and the high bit
423426 * of the request ID indicates resend requests
427+ * FUSE_ALLOW_IDMAP: allow creation of idmapped mounts
424428 */
425429 #define FUSE_ASYNC_READ (1 << 0)
426430 #define FUSE_POSIX_LOCKS (1 << 1)
@@ -466,6 +470,7 @@ struct fuse_file_lock { · 39 unmodified lines
466470
467471 /* Obsolete alias for FUSE_DIRECT_IO_ALLOW_MMAP */
468472 #define FUSE_DIRECT_IO_RELAX FUSE_DIRECT_IO_ALLOW_MMAP
473+#define FUSE_ALLOW_IDMAP (1ULL << 40)
469474
470475 /**
471476 * CUSE INIT request/reply flags
@@ -984,6 +989,19 @@ struct fuse_fallocate_in { · 512 unmodified lines
984989 */
985990 #define FUSE_UNIQUE_RESEND (1ULL << 63)
986991
992+/**
993+ * This value will be set by the kernel to
994+ * (struct fuse_in_header).{uid,gid} fields in
995+ * case when:
996+ * - fuse daemon enabled FUSE_ALLOW_IDMAP
997+ * - idmapping information is not available and uid/gid
998+ * can not be mapped in accordance with an idmapping.
999+ *
1000+ * Note: an idmapping information always available
1001+ * for inode creation operations like:
1002+ * FUSE_MKNOD, FUSE_SYMLINK, FUSE_MKDIR, FUSE_TMPFILE,
1003+ * FUSE_CREATE and FUSE_RENAME2 (with RENAME_WHITEOUT).
1004+ */
9871005 #define FUSE_INVALID_UIDGID ((uint32_t)(-1))
9881006
9891007 struct fuse_in_header {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t