diff options
author | Sage Weil <sage@newdream.net> | 2011-07-26 11:30:29 -0700 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2011-07-26 11:30:29 -0700 |
commit | 5f21c96dd5c615341963036ae8f5e4f5227a818d (patch) | |
tree | 898c5781623b68527427d201e3f975827d08935c /fs/ceph/inode.c | |
parent | 48d0cbd1242aac969560ef8b90f26ee3b09a6a5c (diff) | |
download | lwn-5f21c96dd5c615341963036ae8f5e4f5227a818d.tar.gz lwn-5f21c96dd5c615341963036ae8f5e4f5227a818d.zip |
ceph: protect access to d_parent
d_parent is protected by d_lock: use it when looking up a dentry's parent
directory inode. Also take a reference and drop it in the caller to avoid
a use-after-free.
Reported-by: Al Viro <viro@ZenIV.linux.org.uk>
Reviewed-by: Yehuda Sadeh <yehuda@hq.newdream.net>
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph/inode.c')
-rw-r--r-- | fs/ceph/inode.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 2717dc4e443c..a7db56f1523b 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -1562,7 +1562,7 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr) { struct inode *inode = dentry->d_inode; struct ceph_inode_info *ci = ceph_inode(inode); - struct inode *parent_inode = dentry->d_parent->d_inode; + struct inode *parent_inode; const unsigned int ia_valid = attr->ia_valid; struct ceph_mds_request *req; struct ceph_mds_client *mdsc = ceph_sb_to_client(dentry->d_sb)->mdsc; @@ -1745,7 +1745,9 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr) req->r_inode_drop = release; req->r_args.setattr.mask = cpu_to_le32(mask); req->r_num_caps = 1; + parent_inode = ceph_get_dentry_parent_inode(dentry); err = ceph_mdsc_do_request(mdsc, parent_inode, req); + iput(parent_inode); } dout("setattr %p result=%d (%s locally, %d remote)\n", inode, err, ceph_cap_string(dirtied), mask); |