From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Serge E. Hallyn" Subject: Re: [REVIEW][PATCH 1/3] vfs: In d_path don't call d_dname on a mount point Date: Wed, 27 Nov 2013 01:58:15 +0000 Message-ID: <20131127015815.GD31364@mail.hallyn.com> References: <20131116164840.GA4441@mail.hallyn.com> <20131117030653.GA7670@mail.hallyn.com> <20131118031932.GA17621@mail.hallyn.com> <52899D09.5080202@cn.fujitsu.com> <20131118140830.GA22075@mail.hallyn.com> <20131118180134.GA24156@mail.hallyn.com> <87k3g5gnuv.fsf@xmission.com> <20131126181043.GA25492@mail.hallyn.com> <87siui1z1g.fsf_-_@xmission.com> <8738mi1yya.fsf_-_@xmission.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: "Serge E. Hallyn" , Gao feng , Containers , linux-fsdevel@vger.kernel.org, Aditya Kali , Oleg Nesterov , Andy Lutomirski To: "Eric W. Biederman" Return-path: Received: from static.92.5.9.176.clients.your-server.de ([176.9.5.92]:57601 "EHLO hallynmail2" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1758991Ab3K0B6Q (ORCPT ); Tue, 26 Nov 2013 20:58:16 -0500 Content-Disposition: inline In-Reply-To: <8738mi1yya.fsf_-_@xmission.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Quoting Eric W. Biederman (ebiederm@xmission.com): > > 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//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. > > CC: stable@vger.kernel.org > Reported-by: Aditya Kali > Signed-off-by: "Eric W. Biederman" Acked-by: Serge Hallyn > --- > fs/dcache.c | 7 ++++++- > 1 files changed, 6 insertions(+), 1 deletions(-) > > diff --git a/fs/dcache.c b/fs/dcache.c > index 4bdb300b16e2..f7282ebf1a37 100644 > --- a/fs/dcache.c > +++ b/fs/dcache.c > @@ -3061,8 +3061,13 @@ char *d_path(const struct path *path, char *buf, int buflen) > * thus don't need to be hashed. They also don't need a name until a > * user wants to identify the object in /proc/pid/fd/. The little hack > * below allows us to generate a name for these objects on demand: > + * > + * Some pseudo inodes are mountable. When they are mounted > + * path->dentry == path->mnt->mnt_root. In that case don't call d_dname > + * and instead have d_path return the mounted path. > */ > - if (path->dentry->d_op && path->dentry->d_op->d_dname) > + if (path->dentry->d_op && path->dentry->d_op->d_dname && > + (!IS_ROOT(path->dentry) || path->dentry != path->mnt->mnt_root)) > return path->dentry->d_op->d_dname(path->dentry, buf, buflen); > > rcu_read_lock(); > -- > 1.7.5.4