aboutsummaryrefslogtreecommitdiffstats
path: root/fs/9p
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2013-02-28 01:50:20 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2013-02-28 01:50:20 -0500
commit5e608671dfbfd6a9556c31df65a4f147439eed59 (patch)
treebb708c0bec27822d68defc54d8c79289b29d21fb /fs/9p
parenta3b2157e72e321fa313389ac744bbf6d6cb6986d (diff)
9p: if v9fs_fid_lookup() gets to asking server, it'd better have hashed dentry
... otherwise the path we'd built isn't worth much. Don't accept such fids obtained from paths unless dentry is still alived by the end of the work. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/9p')
-rw-r--r--fs/9p/fid.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/fs/9p/fid.c b/fs/9p/fid.c
index 73ca55042cb0..616abaf1c6cd 100644
--- a/fs/9p/fid.c
+++ b/fs/9p/fid.c
@@ -41,10 +41,15 @@
41 * 41 *
42 */ 42 */
43 43
44static inline void __add_fid(struct dentry *dentry, struct p9_fid *fid)
45{
46 hlist_add_head(&fid->dlist, (struct hlist_head *)&dentry->d_fsdata);
47}
48
44void v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid) 49void v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid)
45{ 50{
46 spin_lock(&dentry->d_lock); 51 spin_lock(&dentry->d_lock);
47 hlist_add_head(&fid->dlist, (struct hlist_head *)&dentry->d_fsdata); 52 __add_fid(dentry, fid);
48 spin_unlock(&dentry->d_lock); 53 spin_unlock(&dentry->d_lock);
49} 54}
50 55
@@ -198,8 +203,17 @@ static struct p9_fid *v9fs_fid_lookup_with_uid(struct dentry *dentry,
198 } 203 }
199 kfree(wnames); 204 kfree(wnames);
200fid_out: 205fid_out:
201 if (!IS_ERR(fid)) 206 if (!IS_ERR(fid)) {
202 v9fs_fid_add(dentry, fid); 207 spin_lock(&dentry->d_lock);
208 if (d_unhashed(dentry)) {
209 spin_unlock(&dentry->d_lock);
210 p9_client_clunk(fid);
211 fid = ERR_PTR(-ENOENT);
212 } else {
213 __add_fid(dentry, fid);
214 spin_unlock(&dentry->d_lock);
215 }
216 }
203err_out: 217err_out:
204 up_read(&v9ses->rename_sem); 218 up_read(&v9ses->rename_sem);
205 return fid; 219 return fid;