Skip to content

Commit

Permalink
fs/9p: Add fid before dentry instantiation
Browse files Browse the repository at this point in the history
d_instantiate marks the dentry positive. So a parallel lookup and mkdir of
the directory can find dentry that doesn't have fid attached. This can result
in both the code path doing v9fs_fid_add which results in v9fs_dentry leak.

Signed-off-by: Aneesh Kumar K.V <[email protected]>
Signed-off-by: Eric Van Hensbergen <[email protected]>
  • Loading branch information
kvaneesh authored and ericvh committed Sep 6, 2011
1 parent ddf2835 commit 5441ae5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 1 addition & 3 deletions fs/9p/vfs_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -645,13 +645,11 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir,
P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n", err);
goto error;
}
d_instantiate(dentry, inode);
err = v9fs_fid_add(dentry, fid);
if (err < 0)
goto error;

d_instantiate(dentry, inode);
return ofid;

error:
if (ofid)
p9_client_clunk(ofid);
Expand Down
8 changes: 4 additions & 4 deletions fs/9p/vfs_inode_dotl.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,10 @@ v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int omode,
P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n", err);
goto error;
}
d_instantiate(dentry, inode);
err = v9fs_fid_add(dentry, fid);
if (err < 0)
goto error;
d_instantiate(dentry, inode);

/* Now set the ACL based on the default value */
v9fs_set_create_acl(dentry, &dacl, &pacl);
Expand Down Expand Up @@ -403,10 +403,10 @@ static int v9fs_vfs_mkdir_dotl(struct inode *dir,
err);
goto error;
}
d_instantiate(dentry, inode);
err = v9fs_fid_add(dentry, fid);
if (err < 0)
goto error;
d_instantiate(dentry, inode);
fid = NULL;
} else {
/*
Expand Down Expand Up @@ -657,10 +657,10 @@ v9fs_vfs_symlink_dotl(struct inode *dir, struct dentry *dentry,
err);
goto error;
}
d_instantiate(dentry, inode);
err = v9fs_fid_add(dentry, fid);
if (err < 0)
goto error;
d_instantiate(dentry, inode);
fid = NULL;
} else {
/* Not in cached mode. No need to populate inode with stat */
Expand Down Expand Up @@ -810,10 +810,10 @@ v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, int omode,
err);
goto error;
}
d_instantiate(dentry, inode);
err = v9fs_fid_add(dentry, fid);
if (err < 0)
goto error;
d_instantiate(dentry, inode);
fid = NULL;
} else {
/*
Expand Down

0 comments on commit 5441ae5

Please sign in to comment.