Skip to contentSkip to conversation

RDMA/uverbs: potential integer overflow

PATCH In review Dan Carpenter 2 participants 2 messages Dec 1, 2011 – Jun 11, 2012 1 message not in the archive

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

PATCH 1/1 RDMA/uverbs: potential integer overflow

This is a static checker fix, and I'm not super familiar with this code.

My checker complains that user_wr->num_sge + sg_ind can have an integer overflow and wrap. That's is true, but I don't know the code well enough to say if it's a problem or not.

Can someone take a look at this?

drivers/infiniband/core/uverbs_cmd.c +4 -2
index 254f164..e57b6d7 100644
@@ -1939,7 +1939,8 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
 			goto out_put;
 		}
 
-		if (user_wr->num_sge + sg_ind > cmd.sge_count) {
+		if (user_wr->num_sge > cmd.sge_count ||
+				user_wr->num_sge + sg_ind > cmd.sge_count) {
 			ret = -EINVAL;
 			goto out_put;
 		}
@@ -2085,7 +2086,8 @@ static struct ib_recv_wr *ib_uverbs_unmarshall_recv(const char __user *buf,
 			goto err;
 		}
 
-		if (user_wr->num_sge + sg_ind > sge_count) {
+		if (user_wr->num_sge > sge_count ||
+				user_wr->num_sge + sg_ind > sge_count) {
 			ret = -EINVAL;
 			goto err;
 		}

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

I was looking through old integer overflows, and I was still wondering if this is buggy.

regards,
dan carpenter

Quoted 43 lines · Dan Carpenter

This is a static checker fix, and I'm not super familiar with this code.

My checker complains that user_wr->num_sge + sg_ind can have an integer overflow and wrap. That's is true, but I don't know the code well enough to say if it's a problem or not.

Can someone take a look at this?

drivers/infiniband/core/uverbs_cmd.c +2 -1
index 254f164..e57b6d7 100644
@@ -1939,7 +1939,8 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file
 *file,
 			goto out_put;
 		}
 
-		if (user_wr->num_sge + sg_ind > cmd.sge_count) {
+		if (user_wr->num_sge > cmd.sge_count ||
+				user_wr->num_sge + sg_ind > cmd.sge_count) {
 			ret = -EINVAL;
 			goto out_put;
drivers/infiniband/core/uverbs_cmd.c +2 -1
 		}
@@ -2085,7 +2086,8 @@ static struct ib_recv_wr
 *ib_uverbs_unmarshall_recv(const char __user *buf,
 			goto err;
 		}
 
-		if (user_wr->num_sge + sg_ind > sge_count) {
+		if (user_wr->num_sge > sge_count ||
+				user_wr->num_sge + sg_ind > sge_count) {
 			ret = -EINVAL;
 			goto err;

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