linux/include/uapi
Aleksa Sarai 4356d575ef fhandle: expose u64 mount id to name_to_handle_at(2)
Now that we provide a unique 64-bit mount ID interface in statx(2), we
can now provide a race-free way for name_to_handle_at(2) to provide a
file handle and corresponding mount without needing to worry about
racing with /proc/mountinfo parsing or having to open a file just to do
statx(2).

While this is not necessary if you are using AT_EMPTY_PATH and don't
care about an extra statx(2) call, users that pass full paths into
name_to_handle_at(2) need to know which mount the file handle comes from
(to make sure they don't try to open_by_handle_at a file handle from a
different filesystem) and switching to AT_EMPTY_PATH would require
allocating a file for every name_to_handle_at(2) call, turning

  err = name_to_handle_at(-EBADF, "/foo/bar/baz", &handle, &mntid,
                          AT_HANDLE_MNT_ID_UNIQUE);

into

  int fd = openat(-EBADF, "/foo/bar/baz", O_PATH | O_CLOEXEC);
  err1 = name_to_handle_at(fd, "", &handle, &unused_mntid, AT_EMPTY_PATH);
  err2 = statx(fd, "", AT_EMPTY_PATH, STATX_MNT_ID_UNIQUE, &statxbuf);
  mntid = statxbuf.stx_mnt_id;
  close(fd);

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
Link: https://lore.kernel.org/r/20240828-exportfs-u64-mount-id-v3-2-10c2c4c16708@cyphar.com
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
2024-09-05 11:39:17 +02:00
..
asm-generic uretprobe: change syscall number, again 2024-08-02 15:18:49 +02:00
drm drm next for 6.11-rc1: 2024-07-18 09:34:02 -07:00
linux fhandle: expose u64 mount id to name_to_handle_at(2) 2024-09-05 11:39:17 +02:00
misc Revert "misc: fastrpc: Restrict untrusted app to attach to privileged PD" 2024-08-15 16:59:14 +02:00
mtd ubi: fastmap: Add control in 'UBI_IOCATT' ioctl to reserve PEBs for filling pools 2023-10-28 23:16:00 +02:00
rdma RDMA/core: Introduce "name_assign_type" for an IB device 2024-07-04 07:59:53 +03:00
regulator uapi: regulator: Fix typo 2024-01-04 13:22:24 +00:00
scsi scsi: mpi3mr: Add ioctl support for HDB 2024-06-26 23:30:09 -04:00
sound ALSA: seq: Add tempo base unit for MIDI2 Set Tempo messages 2024-07-06 09:38:27 +02:00
video
xen xen/gntalloc: Replace UAPI 1-element array 2024-02-13 09:06:48 +01:00
Kbuild