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/ioctl.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/ioctl.c')
-rw-r--r-- | fs/ceph/ioctl.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c index a757a5680578..3b256b50f7d8 100644 --- a/fs/ceph/ioctl.c +++ b/fs/ceph/ioctl.c | |||
@@ -38,7 +38,7 @@ static long ceph_ioctl_get_layout(struct file *file, void __user *arg) | |||
38 | static long ceph_ioctl_set_layout(struct file *file, void __user *arg) | 38 | static long ceph_ioctl_set_layout(struct file *file, void __user *arg) |
39 | { | 39 | { |
40 | struct inode *inode = file->f_dentry->d_inode; | 40 | struct inode *inode = file->f_dentry->d_inode; |
41 | struct inode *parent_inode = file->f_dentry->d_parent->d_inode; | 41 | struct inode *parent_inode; |
42 | struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc; | 42 | struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc; |
43 | struct ceph_mds_request *req; | 43 | struct ceph_mds_request *req; |
44 | struct ceph_ioctl_layout l; | 44 | struct ceph_ioctl_layout l; |
@@ -87,7 +87,9 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg) | |||
87 | req->r_args.setlayout.layout.fl_pg_preferred = | 87 | req->r_args.setlayout.layout.fl_pg_preferred = |
88 | cpu_to_le32(l.preferred_osd); | 88 | cpu_to_le32(l.preferred_osd); |
89 | 89 | ||
90 | parent_inode = ceph_get_dentry_parent_inode(file->f_dentry); | ||
90 | err = ceph_mdsc_do_request(mdsc, parent_inode, req); | 91 | err = ceph_mdsc_do_request(mdsc, parent_inode, req); |
92 | iput(parent_inode); | ||
91 | ceph_mdsc_put_request(req); | 93 | ceph_mdsc_put_request(req); |
92 | return err; | 94 | return err; |
93 | } | 95 | } |