aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2013-11-08 19:31:29 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-01-25 11:27:11 -0500
commit3717eee3c4d1d44ded3bd84bf5f6437ec2aa5496 (patch)
tree58d0c80e5665241c3b53fbdaf53761939d665db0 /fs
parente4832e92ecd957595937e15b0e4b98c8b2b68d1a (diff)
vfs: In d_path don't call d_dname on a mount point
commit f48cfddc6729ef133933062320039808bafa6f45 upstream. Aditya Kali (adityakali@google.com) wrote: > Commit bf056bfa80596a5d14b26b17276a56a0dcb080e5: > "proc: Fix the namespace inode permission checks." converted > the namespace files into symlinks. The same commit changed > the way namespace bind mounts appear in /proc/mounts: > $ mount --bind /proc/self/ns/ipc /mnt/ipc > Originally: > $ cat /proc/mounts | grep ipc > proc /mnt/ipc proc rw,nosuid,nodev,noexec 0 0 > > After commit bf056bfa80596a5d14b26b17276a56a0dcb080e5: > $ cat /proc/mounts | grep ipc > proc ipc:[4026531839] proc rw,nosuid,nodev,noexec 0 0 > > This breaks userspace which expects the 2nd field in > /proc/mounts to be a valid path. The symlink /proc/<pid>/ns/{ipc,mnt,net,pid,user,uts} point to dentries allocated with d_alloc_pseudo that we can mount, and that have interesting names printed out with d_dname. When these files are bind mounted /proc/mounts is not currently displaying the mount point correctly because d_dname is called instead of just displaying the path where the file is mounted. Solve this by adding an explicit check to distinguish mounted pseudo inodes and unmounted pseudo inodes. Unmounted pseudo inodes always use mount of their filesstem as the mnt_root in their path making these two cases easy to distinguish. Acked-by: Serge Hallyn <serge.hallyn@canonical.com> Reported-by: Aditya Kali <adityakali@google.com> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/dcache.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/fs/dcache.c b/fs/dcache.c
index da89cdfb21ab..9a59653d3449 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -2686,8 +2686,13 @@ char *d_path(const struct path *path, char *buf, int buflen)
2686 * thus don't need to be hashed. They also don't need a name until a 2686 * thus don't need to be hashed. They also don't need a name until a
2687 * user wants to identify the object in /proc/pid/fd/. The little hack 2687 * user wants to identify the object in /proc/pid/fd/. The little hack
2688 * below allows us to generate a name for these objects on demand: 2688 * below allows us to generate a name for these objects on demand:
2689 *
2690 * Some pseudo inodes are mountable. When they are mounted
2691 * path->dentry == path->mnt->mnt_root. In that case don't call d_dname
2692 * and instead have d_path return the mounted path.
2689 */ 2693 */
2690 if (path->dentry->d_op && path->dentry->d_op->d_dname) 2694 if (path->dentry->d_op && path->dentry->d_op->d_dname &&
2695 (!IS_ROOT(path->dentry) || path->dentry != path->mnt->mnt_root))
2691 return path->dentry->d_op->d_dname(path->dentry, buf, buflen); 2696 return path->dentry->d_op->d_dname(path->dentry, buf, buflen);
2692 2697
2693 get_fs_root(current->fs, &root); 2698 get_fs_root(current->fs, &root);