From mboxrd@z Thu Jan 1 00:00:00 1970 From: Al Viro Subject: Re: [PATCH 01/13] VFS: replace {, total_}link_count in task_struct with pointer to nameidata Date: Mon, 16 Mar 2015 19:46:22 +0000 Message-ID: <20150316194622.GA29656@ZenIV.linux.org.uk> References: <20150316043602.23648.52734.stgit@notabene.brown> <20150316044319.23648.13820.stgit@notabene.brown> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org To: NeilBrown Return-path: Content-Disposition: inline In-Reply-To: <20150316044319.23648.13820.stgit@notabene.brown> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Mon, Mar 16, 2015 at 03:43:19PM +1100, NeilBrown wrote: > - if (unlikely(current->total_link_count >= 40)) > + if (unlikely(current->nameidata->total_link_count >= 40)) Huh? nd->total_link_count, please. > > - current->total_link_count++; > + current->nameidata->total_link_count++; Similar. > @@ -991,8 +1008,8 @@ static int follow_automount(struct path *path, unsigned flags, > path->dentry->d_inode) > return -EISDIR; > > - current->total_link_count++; > - if (current->total_link_count >= 40) > + current->nameidata->total_link_count++; > + if (current->nameidata->total_link_count >= 40) > return -ELOOP; We probably ought to pass nd through follow_mount / follow_automount, instead of nd->flags, and use nd->total_link_count here. > - if (unlikely(current->link_count >= MAX_NESTED_LINKS)) { > + if (unlikely(current->nameidata->link_count >= MAX_NESTED_LINKS)) { Again, nd->link_count. > @@ -1948,7 +1965,7 @@ static int path_init(int dfd, const char *name, unsigned int flags, > rcu_read_unlock(); > return -ECHILD; > done: > - current->total_link_count = 0; > + current->nameidata->total_link_count = 0; ... and again. > return link_path_walk(name, nd); > } > > @@ -2027,7 +2044,9 @@ static int path_lookupat(int dfd, const char *name, > static int filename_lookup(int dfd, struct filename *name, > unsigned int flags, struct nameidata *nd) > { > - int retval = path_lookupat(dfd, name->name, flags | LOOKUP_RCU, nd); > + int retval; > + struct nameidata *saved_nd = set_nameidata(nd); I'm not sure it's the right place ;-/ I'll play with that a bit and see if I can get it cleaner... > - struct nameidata nd; > + struct nameidata nd, *saved = set_nameidata(&nd); > void *cookie; > int res; > > @@ -4441,6 +4465,7 @@ int generic_readlink(struct dentry *dentry, char __user *buffer, int buflen) > res = readlink_copy(buffer, buflen, nd_get_link(&nd)); > if (dentry->d_inode->i_op->put_link) > dentry->d_inode->i_op->put_link(dentry, &nd, cookie); > + set_nameidata(saved); > return res; Now, _that_ is broken - get ERR_PTR(...) from ->follow_link() and you've leaked nameidata.