Skip to content

Commit 45f2e08

Browse files
author
Sage Weil
committed
ceph: avoid divide by zero in __validate_layout()
If "l->stripe_unit" is zero the the mod on the next line will cause a divide by zero bug. This comes from the copy_from_user() in ceph_ioctl_set_layout_policy(). Passing 0 is valid, though (it means "do not change") so avoid the % check in that case. Reported-by: Dan Carpenter <[email protected]> Signed-off-by: Sage Weil <[email protected]> Reviewed-by: Alex Elder <[email protected]>
1 parent 6d4221b commit 45f2e08

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/ceph/ioctl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ static long __validate_layout(struct ceph_mds_client *mdsc,
4242
/* validate striping parameters */
4343
if ((l->object_size & ~PAGE_MASK) ||
4444
(l->stripe_unit & ~PAGE_MASK) ||
45-
((unsigned)l->object_size % (unsigned)l->stripe_unit))
45+
(l->stripe_unit != 0 &&
46+
((unsigned)l->object_size % (unsigned)l->stripe_unit)))
4647
return -EINVAL;
4748

4849
/* make sure it's a valid data pool */

0 commit comments

Comments
 (0)