History

Merge tag 'vfs-6.15-rc1.mount' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs

Pull vfs mount updates from Christian Brauner: - Mount notifications The day has come where we finally provide a new api to listen for mount topology changes outside of /proc/<pid>/mountinfo. A mount namespace file descriptor can be supplied and registered with fanotify to listen for mount topology changes. Currently notifications for mount, umount and moving mounts are generated. The generated notification record contains the unique mount id of the mount. The listmount() and statmount() api can be used to query detailed information about the mount using the received unique mount id. This allows userspace to figure out exactly how the mount topology changed without having to generating diffs of /proc/<pid>/mountinfo in userspace. - Support O_PATH file descriptors with FSCONFIG_SET_FD in the new mount api - Support detached mounts in overlayfs Since last cycle we support specifying overlayfs layers via file descriptors. However, we don't allow detached mounts which means userspace cannot user file descriptors received via open_tree(OPEN_TREE_CLONE) and fsmount() directly. They have to attach them to a mount namespace via move_mount() first. This is cumbersome and means they have to undo mounts via umount(). Allow them to directly use detached mounts. - Allow to retrieve idmappings with statmount Currently it isn't possible to figure out what idmapping has been attached to an idmapped mount. Add an extension to statmount() which allows to read the idmapping from the mount. - Allow creating idmapped mounts from mounts that are already idmapped So far it isn't possible to allow the creation of idmapped mounts from already idmapped mounts as this has significant lifetime implications. Make the creation of idmapped mounts atomic by allow to pass struct mount_attr together with the open_tree_attr() system call allowing to solve these issues without complicating VFS lookup in any way. The system call has in general the benefit that creating a detached mount and applying mount attributes to it becomes an atomic operation for userspace. - Add a way to query statmount() for supported options Allow userspace to query which mount information can be retrieved through statmount(). - Allow superblock owners to force unmount * tag 'vfs-6.15-rc1.mount' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs: (21 commits) umount: Allow superblock owners to force umount selftests: add tests for mount notification selinux: add FILE__WATCH_MOUNTNS samples/vfs: fix printf format string for size_t fs: allow changing idmappings fs: add kflags member to struct mount_kattr fs: add open_tree_attr() fs: add copy_mount_setattr() helper fs: add vfs_open_tree() helper statmount: add a new supported_mask field samples/vfs: add STATMOUNT_MNT_{G,U}IDMAP selftests: add tests for using detached mount with overlayfs samples/vfs: check whether flag was raised statmount: allow to retrieve idmappings uidgid: add map_id_range_up() fs: allow detached mounts in clone_private_mount() selftests/overlayfs: test specifying layers as O_PATH file descriptors fs: support O_PATH fds with FSCONFIG_SET_FD vfs: add notifications for mount attach and detach fanotify: notify on mount attach and detach ...

Linus Torvalds committed 1 year ago

Commit fd101da2 parents a79a09a e1ff7aa52 files · +1567 −175Browse files

Showing the changes to include/uapi (3 of 52 files). Show all

Unified · Split

3 files
  1. include/uapi/asm-generic/unistd.h +3 −1
  2. include/uapi/linux/fanotify.h +10 −0
  3. include/uapi/linux/mount.h +9 −1
include/uapi/asm-generic/unistd.h+3−1
@@ -849,9 +849,11 @@ __SYSCALL(__NR_getxattrat, sys_getxattrat) · 848 unmodified lines
849849 __SYSCALL(__NR_listxattrat, sys_listxattrat)
850850 #define __NR_removexattrat 466
851851 __SYSCALL(__NR_removexattrat, sys_removexattrat)
852+#define __NR_open_tree_attr 467
853+__SYSCALL(__NR_open_tree_attr, sys_open_tree_attr)
852854
853855 #undef __NR_syscalls
854−#define __NR_syscalls 467
856+#define __NR_syscalls 468
855857
856858 /*
857859 * 32 bit systems traditionally used different
include/uapi/linux/fanotify.h+10−0
@@ -28,6 +28,8 @@ · 27 unmodified lines
2828 /* #define FAN_DIR_MODIFY 0x00080000 */ /* Deprecated (reserved) */
2929
3030 #define FAN_PRE_ACCESS 0x00100000 /* Pre-content access hook */
31+#define FAN_MNT_ATTACH 0x01000000 /* Mount was attached */
32+#define FAN_MNT_DETACH 0x02000000 /* Mount was detached */
3133
3234 #define FAN_EVENT_ON_CHILD 0x08000000 /* Interested in child events */
3335
@@ -64,6 +66,7 @@ · 30 unmodified lines
6466 #define FAN_REPORT_NAME 0x00000800 /* Report events with name */
6567 #define FAN_REPORT_TARGET_FID 0x00001000 /* Report dirent target id */
6668 #define FAN_REPORT_FD_ERROR 0x00002000 /* event->fd can report error */
69+#define FAN_REPORT_MNT 0x00004000 /* Report mount events */
6770
6871 /* Convenience macro - FAN_REPORT_NAME requires FAN_REPORT_DIR_FID */
6972 #define FAN_REPORT_DFID_NAME (FAN_REPORT_DIR_FID | FAN_REPORT_NAME)
@@ -94,6 +97,7 @@ · 24 unmodified lines
9497 #define FAN_MARK_INODE 0x00000000
9598 #define FAN_MARK_MOUNT 0x00000010
9699 #define FAN_MARK_FILESYSTEM 0x00000100
100+#define FAN_MARK_MNTNS 0x00000110
97101
98102 /*
99103 * Convenience macro - FAN_MARK_IGNORE requires FAN_MARK_IGNORED_SURV_MODIFY
@@ -147,6 +151,7 @@ struct fanotify_event_metadata { · 47 unmodified lines
147151 #define FAN_EVENT_INFO_TYPE_PIDFD 4
148152 #define FAN_EVENT_INFO_TYPE_ERROR 5
149153 #define FAN_EVENT_INFO_TYPE_RANGE 6
154+#define FAN_EVENT_INFO_TYPE_MNT 7
150155
151156 /* Special info types for FAN_RENAME */
152157 #define FAN_EVENT_INFO_TYPE_OLD_DFID_NAME 10
@@ -200,6 +205,11 @@ struct fanotify_event_info_range { · 47 unmodified lines
200205 __u64 count;
201206 };
202207
208+struct fanotify_event_info_mnt {
209+ struct fanotify_event_info_header hdr;
210+ __u64 mnt_id;
211+};
212+
203213 /*
204214 * User space may need to record additional information about its decision.
205215 * The extra information type records what kind of information is included.
include/uapi/linux/mount.h+9−1
@@ -179,7 +179,12 @@ struct statmount { · 178 unmodified lines
179179 __u32 opt_array; /* [str] Array of nul terminated fs options */
180180 __u32 opt_sec_num; /* Number of security options */
181181 __u32 opt_sec_array; /* [str] Array of nul terminated security options */
182− __u64 __spare2[46];
182+ __u64 supported_mask; /* Mask flags that this kernel supports */
183+ __u32 mnt_uidmap_num; /* Number of uid mappings */
184+ __u32 mnt_uidmap; /* [str] Array of uid mappings (as seen from callers namespace) */
185+ __u32 mnt_gidmap_num; /* Number of gid mappings */
186+ __u32 mnt_gidmap; /* [str] Array of gid mappings (as seen from callers namespace) */
187+ __u64 __spare2[43];
183188 char str[]; /* Variable size part containing strings */
184189 };
185190
@@ -217,6 +222,9 @@ struct mnt_id_req { · 31 unmodified lines
217222 #define STATMOUNT_SB_SOURCE 0x00000200U /* Want/got sb_source */
218223 #define STATMOUNT_OPT_ARRAY 0x00000400U /* Want/got opt_... */
219224 #define STATMOUNT_OPT_SEC_ARRAY 0x00000800U /* Want/got opt_sec... */
225+#define STATMOUNT_SUPPORTED_MASK 0x00001000U /* Want/got supported mask flags */
226+#define STATMOUNT_MNT_UIDMAP 0x00002000U /* Want/got uidmap... */
227+#define STATMOUNT_MNT_GIDMAP 0x00004000U /* Want/got gidmap... */
220228
221229 /*
222230 * Special @mnt_id values that can be passed to listmount