diff options
author | Sage Weil <sage@inktank.com> | 2012-09-25 00:04:57 -0400 |
---|---|---|
committer | Alex Elder <elder@inktank.com> | 2012-10-03 11:51:17 -0400 |
commit | 457712a0bc5389b75d2c93840a684fd77df2aabb (patch) | |
tree | 465703170a567b747a1e642a6a80332e0bdbf1f1 /fs/ceph | |
parent | 6cae3717cddaf8e5e96e304733dca66e40d56f89 (diff) |
ceph: return EIO on invalid layout on GET_DATALOC ioctl
If the user calls GET_DATALOC on a file with an invalid (e.g.,
zeroed) layout, return EIO to userland.
Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Alex Elder <elder@inktank.com>
Diffstat (limited to 'fs/ceph')
-rw-r--r-- | fs/ceph/ioctl.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c index 1396ceb4679..36549a46e31 100644 --- a/fs/ceph/ioctl.c +++ b/fs/ceph/ioctl.c | |||
@@ -187,14 +187,18 @@ static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg) | |||
187 | u64 tmp; | 187 | u64 tmp; |
188 | struct ceph_object_layout ol; | 188 | struct ceph_object_layout ol; |
189 | struct ceph_pg pgid; | 189 | struct ceph_pg pgid; |
190 | int r; | ||
190 | 191 | ||
191 | /* copy and validate */ | 192 | /* copy and validate */ |
192 | if (copy_from_user(&dl, arg, sizeof(dl))) | 193 | if (copy_from_user(&dl, arg, sizeof(dl))) |
193 | return -EFAULT; | 194 | return -EFAULT; |
194 | 195 | ||
195 | down_read(&osdc->map_sem); | 196 | down_read(&osdc->map_sem); |
196 | ceph_calc_file_object_mapping(&ci->i_layout, dl.file_offset, &len, | 197 | r = ceph_calc_file_object_mapping(&ci->i_layout, dl.file_offset, &len, |
197 | &dl.object_no, &dl.object_offset, &olen); | 198 | &dl.object_no, &dl.object_offset, |
199 | &olen); | ||
200 | if (r < 0) | ||
201 | return -EIO; | ||
198 | dl.file_offset -= dl.object_offset; | 202 | dl.file_offset -= dl.object_offset; |
199 | dl.object_size = ceph_file_layout_object_size(ci->i_layout); | 203 | dl.object_size = ceph_file_layout_object_size(ci->i_layout); |
200 | dl.block_size = ceph_file_layout_su(ci->i_layout); | 204 | dl.block_size = ceph_file_layout_su(ci->i_layout); |