diff options
author | Sage Weil <sage@newdream.net> | 2011-07-26 14:30:29 -0400 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2011-07-26 14:30:29 -0400 |
commit | 5f21c96dd5c615341963036ae8f5e4f5227a818d (patch) | |
tree | 898c5781623b68527427d201e3f975827d08935c /fs/ceph/file.c | |
parent | 48d0cbd1242aac969560ef8b90f26ee3b09a6a5c (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/file.c')
-rw-r--r-- | fs/ceph/file.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/fs/ceph/file.c b/fs/ceph/file.c index f34d47d66e7c..45fbd69daabe 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c | |||
@@ -122,7 +122,7 @@ int ceph_open(struct inode *inode, struct file *file) | |||
122 | struct ceph_mds_client *mdsc = fsc->mdsc; | 122 | struct ceph_mds_client *mdsc = fsc->mdsc; |
123 | struct ceph_mds_request *req; | 123 | struct ceph_mds_request *req; |
124 | struct ceph_file_info *cf = file->private_data; | 124 | struct ceph_file_info *cf = file->private_data; |
125 | struct inode *parent_inode = file->f_dentry->d_parent->d_inode; | 125 | struct inode *parent_inode = NULL; |
126 | int err; | 126 | int err; |
127 | int flags, fmode, wanted; | 127 | int flags, fmode, wanted; |
128 | 128 | ||
@@ -194,8 +194,10 @@ int ceph_open(struct inode *inode, struct file *file) | |||
194 | req->r_inode = inode; | 194 | req->r_inode = inode; |
195 | ihold(inode); | 195 | ihold(inode); |
196 | req->r_num_caps = 1; | 196 | req->r_num_caps = 1; |
197 | err = ceph_mdsc_do_request(mdsc, (flags & (O_CREAT|O_TRUNC)) ? | 197 | if (flags & (O_CREAT|O_TRUNC)) |
198 | parent_inode : NULL, req); | 198 | parent_inode = ceph_get_dentry_parent_inode(file->f_dentry); |
199 | err = ceph_mdsc_do_request(mdsc, parent_inode, req); | ||
200 | iput(parent_inode); | ||
199 | if (!err) | 201 | if (!err) |
200 | err = ceph_init_file(inode, file, req->r_fmode); | 202 | err = ceph_init_file(inode, file, req->r_fmode); |
201 | ceph_mdsc_put_request(req); | 203 | ceph_mdsc_put_request(req); |