]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
proc: block mounting on top of /proc/<pid>/fd/*
authorChristian Brauner <brauner@kernel.org>
Tue, 6 Aug 2024 16:02:31 +0000 (18:02 +0200)
committerChristian Brauner <brauner@kernel.org>
Fri, 30 Aug 2024 06:22:13 +0000 (08:22 +0200)
Entries under /proc/<pid>/fd/* are ephemeral and may go away before the
process dies. As such allowing them to be used as mount points creates
the ability to leak mounts that linger until the process dies with no
ability to unmount them until then. Don't allow using them as
mountpoints.

Link: https://lore.kernel.org/r/20240806-work-procfs-v1-5-fb04e1d09f0c@kernel.org
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/proc/fd.c

index 105d6ce5b268441ccc793dc90058d4af6147373d..671a45884304cdd006e0371b09d4ad76cd829439 100644 (file)
@@ -220,8 +220,8 @@ static struct dentry *proc_fd_instantiate(struct dentry *dentry,
        ei->op.proc_get_link = proc_fd_link;
        tid_fd_update_inode(task, inode, data->mode);
 
-       d_set_d_op(dentry, &tid_fd_dentry_operations);
-       return d_splice_alias(inode, dentry);
+       return proc_splice_unmountable(inode, dentry,
+                                      &tid_fd_dentry_operations);
 }
 
 static struct dentry *proc_lookupfd_common(struct inode *dir,