nfsd: vfs_mkdir() might succeed leaving dentry negative unhashed
That can (and does, on some filesystems) happen - ->mkdir() (and thus vfs_mkdir()) can legitimately leave its argument negative and just unhash it, counting upon the lookup to pick the object we'd created next time we try to look at that name. Some vfs_mkdir() callers forget about that possibility... Acked-by: J. Bruce Fields <bfields@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
9c3e9025a3
commit
3819bb0d79
|
@ -1201,6 +1201,28 @@ nfsd_create_locked(struct svc_rqst *rqstp, struct svc_fh *fhp,
|
|||
break;
|
||||
case S_IFDIR:
|
||||
host_err = vfs_mkdir(dirp, dchild, iap->ia_mode);
|
||||
if (!host_err && unlikely(d_unhashed(dchild))) {
|
||||
struct dentry *d;
|
||||
d = lookup_one_len(dchild->d_name.name,
|
||||
dchild->d_parent,
|
||||
dchild->d_name.len);
|
||||
if (IS_ERR(d)) {
|
||||
host_err = PTR_ERR(d);
|
||||
break;
|
||||
}
|
||||
if (unlikely(d_is_negative(d))) {
|
||||
dput(d);
|
||||
err = nfserr_serverfault;
|
||||
goto out;
|
||||
}
|
||||
dput(resfhp->fh_dentry);
|
||||
resfhp->fh_dentry = dget(d);
|
||||
err = fh_update(resfhp);
|
||||
dput(dchild);
|
||||
dchild = d;
|
||||
if (err)
|
||||
goto out;
|
||||
}
|
||||
break;
|
||||
case S_IFCHR:
|
||||
case S_IFBLK:
|
||||
|
|
Loading…
Reference in New Issue