mbox series

[GIT,PULL,for,v6.11] vfs mount

Message ID 20240712-vfs-mount-8fd93381a87f@brauner (mailing list archive)
State New
Headers show
Series [GIT,PULL,for,v6.11] vfs mount | expand

Pull-request

git@gitolite.kernel.org:pub/scm/linux/kernel/git/vfs/vfs tags/vfs-6.11.mount

Message

Christian Brauner July 12, 2024, 1:59 p.m. UTC
Hey Linus,

/* Summary */
This contains work to extend the abilities of listmount() and statmount() and
various fixes and cleanups.

Features:

- Allow iterating through mounts via listmount() from newest to oldest. This
  makes it possible for mount(8) to keep iterating the mount table in reverse
  order so it gets newest mounts first.

- Relax permissions on listmount() and statmount(). It's not necessary to have
  capabilities in the initial namespace. It's sufficient to have capabilities
  in the owning namespace of the mount namespace we're located in to list
  unreachable mounts in that namespace.

- Extend both listmount() and statmount() to list and stat mounts in foreign
  mount namespaces.

  Currently the only way to iterate over mount entries in mount namespaces that
  aren't in the caller's mount namespace is by crawling through /proc in order
  to find /proc/<pid>/mountinfo for the relevant mount namespace. This is both
  very clumsy and hugely inefficient. So extend struct mnt_id_req with a new
  member that allows to specify the mount namespace id of the mount namespace
  we want to look at.

  Luckily internally we already have most of the infrastructure for this so we
  just need to expose it to userspace. Give userspace a way to retrieve the id
  of a mount namespace via statmount() and through a new nsfs ioctl() on mount
  namespace file descriptor.

  This comes with appropriate selftests.

- Expose mount options through statmount().

  Currently if userspace wants to get mount options for a mount and with
  statmount(), they still have to open /proc/<pid>/mountinfo to parse mount
  options. Simply the information through statmount() directly.

  Afterwards it's possible to only rely on statmount() and listmount() to
  retrieve all and more information than /proc/<pid>/mountinfo provides.           

  This comes with appropriate selftests.

Fixes:

- Avoid copying to userspace under the namespace semaphore in listmount.

Cleanups:

- Simplify the error handling in listmount by relying on our newly added
  cleanup infrastructure.

- Refuse invalid mount ids early for both listmount and statmount.

/* Testing */
clang: Debian clang version 16.0.6 (26)
gcc: (Debian 13.2.0-24)

All patches are based on v6.10-rc1 and have been sitting in linux-next.
No build failures or warnings were observed.

/* Conflicts */
No known conflicts.

The following changes since commit 1613e604df0cd359cf2a7fbd9be7a0bcfacfabd0:

  Linux 6.10-rc1 (2024-05-26 15:20:12 -0700)

are available in the Git repository at:

  git@gitolite.kernel.org:pub/scm/linux/kernel/git/vfs/vfs tags/vfs-6.11.mount

for you to fetch changes up to 4bed843b10004d9101b49ac7270131051c39a92b:

  fs: reject invalid last mount id early (2024-07-08 06:32:18 +0200)

Please consider pulling these changes from the signed vfs-6.11.mount tag.

Thanks!
Christian

----------------------------------------------------------------
vfs-6.11.mount

----------------------------------------------------------------
Christian Brauner (15):
      path: add cleanup helper
      fs: don't copy to userspace under namespace semaphore
      fs: simplify error handling
      fs: relax permissions for listmount()
      listmount: allow listing in reverse order
      fs: relax permissions for statmount()
      fs: Allow listmount() in foreign mount namespace
      fs: Allow statmount() in foreign mount namespace
      Merge patch series "Support foreign mount namespace with statmount/listmount"
      fs: use guard for namespace_sem in statmount()
      Merge patch series "Add the ability to query mount options in statmount"
      fs: only copy to userspace on success in listmount()
      fs: find rootfs mount of the mount namespace
      fs: refuse mnt id requests with invalid ids early
      fs: reject invalid last mount id early

Josef Bacik (7):
      fs: keep an index of current mount namespaces
      fs: export the mount ns id via statmount
      fs: add an ioctl to get the mnt ns id from nsfs
      selftests: add a test for the foreign mnt ns extensions
      fs: rename show_mnt_opts -> show_vfsmnt_opts
      fs: export mount options via statmount()
      sefltests: extend the statmount test for mount options

 fs/mount.h                                         |   2 +
 fs/namespace.c                                     | 450 +++++++++++++++++----
 fs/nsfs.c                                          |  14 +
 fs/proc_namespace.c                                |   6 +-
 include/linux/path.h                               |   9 +
 include/uapi/linux/mount.h                         |  10 +-
 include/uapi/linux/nsfs.h                          |   2 +
 .../selftests/filesystems/statmount/Makefile       |   2 +-
 .../selftests/filesystems/statmount/statmount.h    |  46 +++
 .../filesystems/statmount/statmount_test.c         | 144 +++++--
 .../filesystems/statmount/statmount_test_ns.c      | 364 +++++++++++++++++
 11 files changed, 926 insertions(+), 123 deletions(-)
 create mode 100644 tools/testing/selftests/filesystems/statmount/statmount.h
 create mode 100644 tools/testing/selftests/filesystems/statmount/statmount_test_ns.c

Comments

pr-tracker-bot@kernel.org July 15, 2024, 8:34 p.m. UTC | #1
The pull request you sent on Fri, 12 Jul 2024 15:59:50 +0200:

> git@gitolite.kernel.org:pub/scm/linux/kernel/git/vfs/vfs tags/vfs-6.11.mount

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/f608cabaeda472887c008e42398e8fca14e8f411

Thank you!