When mounting procfs with the subset=pids option, all static files become
unavailable and only the dynamic part with information about pids is accessible.
In this case, there is no point in imposing additional restrictions on the
visibility of the entire filesystem for the mounter. Everything that can be
hidden in procfs is already inaccessible.
Currently, these restrictions prevent pidfs from being mounted inside rootless
containers, as almost all container implementations override part of procfs to
hide certain directories. Relaxing these restrictions will allow pidfs to be
used in nested containerization.
---
Changelog
---------
v10:
* Rework visibility checks around Christian's FS_USERNS_MOUNT_RESTRICTED
and SB_I_RESTRICTED_VARIANT approach instead of fs_context skip_visibility.
* Add Christian's sysfs_get_tree() cleanup.
* Treat subset=pid procfs as a restricted variant that is allowed without
mnt_already_visible(), but cannot be used as visibility evidence for later
mounts.
* Forbid changing subset=pid on procfs reconfigure in either direction to
avoid exposing pre-existing overmounts after switching to subset=pid.
* Make failed subset=pid reconfigure leave other procfs options unchanged.
* Update procfs documentation accordingly.
v9:
* Rework the patch based on the one proposed by Christian Brauner.
v8:
* Remove mounter credential change on remount as suggested by Christian Brauner.
v7:
* Rebase on v6.19-rc5.
* Rename SB_I_DYNAMIC to SB_I_USERNS_ALLOW_REVEALING.
v6:
* Add documentation about procfs mount restrictions.
* Reorder commits for better review.
v4:
* Set SB_I_DYNAMIC only if pidonly is set.
* Add an error message if subset=pid is canceled during remount.
v3:
* Add 'const' to struct cred *mounter_cred (fix kernel test robot warning).
v2:
* cache the mounters credentials and make access to the net directories
contingent of the permissions of the mounter of procfs.
Alexey Gladkov (4):
proc: subset=pid: Show /proc/self/net only for CAP_NET_ADMIN
proc: prevent reconfiguring subset=pid
proc: handle subset=pid separately in userns visibility checks
docs: proc: add documentation about mount restrictions
Christian Brauner (3):
namespace: record fully visible mounts in list
fs: move SB_I_USERNS_VISIBLE to FS_USERNS_MOUNT_RESTRICTED
sysfs: remove trivial sysfs_get_tree() wrapper
Documentation/filesystems/proc.rst | 19 ++++++++++++++++-
fs/mount.h | 4 ++++
fs/namespace.c | 34 +++++++++++++++++++++++-------
fs/proc/proc_net.c | 8 +++++++
fs/proc/root.c | 24 +++++++++++++++------
fs/sysfs/mount.c | 18 ++--------------
include/linux/fs.h | 1 +
include/linux/fs/super_types.h | 2 +-
include/linux/proc_fs.h | 1 +
kernel/acct.c | 2 +-
10 files changed, 80 insertions(+), 33 deletions(-)
--
2.54.0