[PATCH 2/7] proc: don't let /proc/self and /proc/thread-self be mountpoints
Christian Brauner
brauner at kernel.org
Sat Oct 24 03:38:28 PDT 2026
/proc/self and /proc/thread-self resolve to a different directory for
every process that walks through them. A mount on one of the links
itself is crossed by every lookup of /proc/self/... in that mount
namespace, so it redirects all processes at once, not just the one that
created the mount. There's no good reason to ever do that.
Mark both links with dont_mount() before they become visible.
Signed-off-by: Christian Brauner (Amutable) <brauner at kernel.org>
---
fs/proc/self.c | 2 ++
fs/proc/thread_self.c | 2 ++
2 files changed, 4 insertions(+)
diff --git a/fs/proc/self.c b/fs/proc/self.c
index 56adf1c68f7a..63120ab7704c 100644
--- a/fs/proc/self.c
+++ b/fs/proc/self.c
@@ -48,6 +48,8 @@ int proc_setup_self(struct super_block *s)
inode->i_uid = GLOBAL_ROOT_UID;
inode->i_gid = GLOBAL_ROOT_GID;
inode->i_op = &proc_self_inode_operations;
+ /* a mount here would redirect every process */
+ dont_mount(self);
d_make_persistent(self, inode);
ret = 0;
}
diff --git a/fs/proc/thread_self.c b/fs/proc/thread_self.c
index 61ac62c3fd9f..a4f803daf589 100644
--- a/fs/proc/thread_self.c
+++ b/fs/proc/thread_self.c
@@ -48,6 +48,8 @@ int proc_setup_thread_self(struct super_block *s)
inode->i_uid = GLOBAL_ROOT_UID;
inode->i_gid = GLOBAL_ROOT_GID;
inode->i_op = &proc_thread_self_inode_operations;
+ /* a mount here would redirect every thread */
+ dont_mount(thread_self);
d_make_persistent(thread_self, inode);
ret = 0;
}
--
2.53.0
More information about the linux-afs
mailing list