Skip to contentSkip to conversation

NFSv4.1: integer overflow in decode_cb_sequence_args()

PATCH New Dan Carpenter 1 participant 1 message Jun 12, 2012

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

PATCH 1/2 NFSv4.1: integer overflow in decode_cb_sequence_args()

This seems like it could overflow on 32 bits. Use kmalloc_array() which has overflow protection built in.

fs/nfs/callback_xdr.c +3 -3
index 95bfc24..27c2969 100644
@@ -455,9 +455,9 @@ static __be32 decode_cb_sequence_args(struct svc_rqst *rqstp,
 	args->csa_nrclists = ntohl(*p++);
 	args->csa_rclists = NULL;
 	if (args->csa_nrclists) {
-		args->csa_rclists = kmalloc(args->csa_nrclists *
-					    sizeof(*args->csa_rclists),
-					    GFP_KERNEL);
+		args->csa_rclists = kmalloc_array(args->csa_nrclists,
+						  sizeof(*args->csa_rclists),
+						  GFP_KERNEL);
 		if (unlikely(args->csa_rclists = NULL))
 			goto out;