Skip to content

Commit

Permalink
ceph: avoid divide by zero in __validate_layout()
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Sage Weil committed Aug 21, 2012
1 parent 6d4221b commit 45f2e08
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/ceph/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ static long __validate_layout(struct ceph_mds_client *mdsc,
/* validate striping parameters */
if ((l->object_size & ~PAGE_MASK) ||
(l->stripe_unit & ~PAGE_MASK) ||
((unsigned)l->object_size % (unsigned)l->stripe_unit))
(l->stripe_unit != 0 &&
((unsigned)l->object_size % (unsigned)l->stripe_unit)))
return -EINVAL;

/* make sure it's a valid data pool */
Expand Down

0 comments on commit 45f2e08

Please sign in to comment.