Skip to content

Support foreign mount namespace with statmount/listmount

Josef Bacik linux-api linux-fsdevel 1 version Applied

Status from this message: Applied to the vfs.mount branch of the vfs/vfs.git tree.

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest8 patches 12 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/8fs: relax permissions for listmount()fs/namespace.c+1 -10 replies
2/8fs: relax permissions for statmount()fs/namespace.c+2 -10 replies
3/8fs: keep an index of current mount namespacesfs/mount.h fs/namespace.c+113 -22 replies
4/8fs: export the mount ns id via statmountfs/namespace.c include/uapi/linux/mount.h+14 -10 replies
5/8fs: Allow listmount() in foreign mount namespacefs/namespace.c include/uapi/linux/mount.h+72 -180 replies
6/8fs: Allow statmount() in foreign mount namespacefs/namespace.c+25 -60 replies
7/8fs: add an ioctl to get the mnt ns id from nsfsfs/nsfs.c include/uapi/linux/nsfs.h+16 -06 replies
8/8selftests: add a test for the foreign mnt ns extensionstools/testing/selftests/filesystems/statmount/Makefile tools/testing/selftests/filesystems/statmount/statmount.h tools/testing/selftests/filesystems/statmount/statmount_test.c +1 more+420 -410 replies

Reviews trailers per patch

None of the 8 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchJeff Layton
SeriesR-b
1/8
2/8
3/8
4/8
5/8
6/8
7/8
8/8

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/8] Support foreign mount namespace with statmount/listmount

Hello,

Currently the only way to iterate over mount entries in mount namespaces that aren't your own is to trawl through /proc in order to find /proc/$PID/mountinfo for the mount namespace that you want. This is hugely inefficient, so extend both statmount() and listmount() to allow specifying a mount namespace id in order to get to mounts in other mount namespaces.

There are a few components to this

1. Having a global index of the mount namespace based on the ->seq value in the mount namespace. This gives us a unique identifier that isn't re-used.
2. Support looking up mount namespaces based on that unique identifier, and validating the user has permission to access the given mount namespace.
3. Provide a new ioctl() on nsfs in order to extract the unique identifier we can use for statmount() and listmount().

The code is relatively straightforward, and there is a selftest provided to validate everything works properly.

This is based on vfs.all as of last week, so must be applied onto a tree that has Christians error handling rework in this area. If you wish you can pull the tree directly here

https://github.com/josefbacik/linux/tree/listmount.combined

Christian and I collaborated on this series, which is why there's patches from both of us in this series.

Josef

Christian Brauner (4):
fs: relax permissions for listmount()
fs: relax permissions for statmount()
fs: Allow listmount() in foreign mount namespace
fs: Allow statmount() in foreign mount namespace

Josef Bacik (4):
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/mount.h                                    |   2 +
 fs/namespace.c                                | 240 ++++++++++--
 fs/nsfs.c                                     |  14 +
 include/uapi/linux/mount.h                    |   6 +-
 include/uapi/linux/nsfs.h                     |   2 +
 .../selftests/filesystems/statmount/Makefile  |   2 +-
 .../filesystems/statmount/statmount.h         |  46 +++
 .../filesystems/statmount/statmount_test.c    |  53 +--
 .../filesystems/statmount/statmount_test_ns.c | 360 ++++++++++++++++++
 9 files changed, 659 insertions(+), 66 deletions(-)
 create mode 100644 tools/testing/selftests/filesystems/statmount/statmount.h
 create mode 100644 tools/testing/selftests/filesystems/statmount/statmount_test_ns.c
Signature · 1 line
2.43.0