Skip to contentSkip to conversation

ceph: divide by zero bug in __validate_layout()

PATCH In review Dan Carpenter 2 participants 2 messages Aug 18, 2012 – Aug 20, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ceph: divide by zero bug 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()

fs/ceph/ioctl.c +1 -0
index 8e3fb69..81ec22b 100644
@@ -42,6 +42,7 @@ static long __validate_layout(struct ceph_mds_client *mdsc,
 	/* validate striping parameters */
 	if ((l->object_size & ~PAGE_MASK) ||
 	    (l->stripe_unit & ~PAGE_MASK) ||
+	    (l->stripe_unit = 0) ||
 	    ((unsigned)l->object_size % (unsigned)l->stripe_unit))
 		return -EINVAL;
 
#1 lore raw

Hi Dan,

I've applied a slightly different fix to the ceph tree that just skips the mod if stripe_unit is 0 but doesn't return EINVAL, since passing 0 is valid (it means 'do not change').

Thanks!
sage

Quoted 24 lines · Dan Carpenter

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()

fs/ceph/ioctl.c +1 -1
index 8e3fb69..81ec22b 100644
@@ -42,6 +42,7 @@ static long __validate_layout(struct ceph_mds_client *mdsc,
 	/* validate striping parameters */
 	if ((l->object_size & ~PAGE_MASK) ||
 	    (l->stripe_unit & ~PAGE_MASK) ||
+	    (l->stripe_unit = 0) ||
 	    ((unsigned)l->object_size % (unsigned)l->stripe_unit))
 		return -EINVAL;
 
--

To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html