aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ceph/inode.c
diff options
context:
space:
mode:
authorSage Weil <sage@newdream.net>2011-07-26 14:30:29 -0400
committerSage Weil <sage@newdream.net>2011-07-26 14:30:29 -0400
commit5f21c96dd5c615341963036ae8f5e4f5227a818d (patch)
tree898c5781623b68527427d201e3f975827d08935c /fs/ceph/inode.c
parent48d0cbd1242aac969560ef8b90f26ee3b09a6a5c (diff)
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.c4
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)
1562{ 1562{
1563 struct inode *inode = dentry->d_inode; 1563 struct inode *inode = dentry->d_inode;
1564 struct ceph_inode_info *ci = ceph_inode(inode); 1564 struct ceph_inode_info *ci = ceph_inode(inode);
1565 struct inode *parent_inode = dentry->d_parent->d_inode; 1565 struct inode *parent_inode;
1566 const unsigned int ia_valid = attr->ia_valid; 1566 const unsigned int ia_valid = attr->ia_valid;
1567 struct ceph_mds_request *req; 1567 struct ceph_mds_request *req;
1568 struct ceph_mds_client *mdsc = ceph_sb_to_client(dentry->d_sb)->mdsc; 1568 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)
1745 req->r_inode_drop = release; 1745 req->r_inode_drop = release;
1746 req->r_args.setattr.mask = cpu_to_le32(mask); 1746 req->r_args.setattr.mask = cpu_to_le32(mask);
1747 req->r_num_caps = 1; 1747 req->r_num_caps = 1;
1748 parent_inode = ceph_get_dentry_parent_inode(dentry);
1748 err = ceph_mdsc_do_request(mdsc, parent_inode, req); 1749 err = ceph_mdsc_do_request(mdsc, parent_inode, req);
1750 iput(parent_inode);
1749 } 1751 }
1750 dout("setattr %p result=%d (%s locally, %d remote)\n", inode, err, 1752 dout("setattr %p result=%d (%s locally, %d remote)\n", inode, err,
1751 ceph_cap_string(dirtied), mask); 1753 ceph_cap_string(dirtied), mask);