@@ -1359,6 +1359,9 @@ ssize_t ib_uverbs_resize_cq(struct ib_uverbs_file *file,
if (in_len < sizeof cmd)
return -EINVAL;
+ if (out_len < sizeof resp)
+ return -ENOSPC;
+
if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT;
@@ -1427,6 +1430,9 @@ ssize_t ib_uverbs_poll_cq(struct ib_uverbs_file *file,
if (in_len < sizeof cmd)
return -EINVAL;
+ if (out_len < sizeof resp)
+ return -ENOSPC;
+
if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT;
@@ -1506,6 +1512,9 @@ ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file,
if (in_len < sizeof cmd)
return -EINVAL;
+ if (out_len < sizeof resp)
+ return -ENOSPC;
+
if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT;
@@ -1855,6 +1864,9 @@ ssize_t ib_uverbs_query_qp(struct ib_uverbs_file *file,
if (in_len < sizeof cmd)
return -EINVAL;
+ if (out_len < sizeof resp)
+ return -ENOSPC;
+
if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT;
@@ -2067,6 +2079,9 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file,
if (in_len < sizeof cmd)
return -EINVAL;
+ if (out_len < sizeof resp)
+ return -ENOSPC;
+
if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT;
@@ -2130,6 +2145,9 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
if (in_len < sizeof cmd)
return -EINVAL;
+ if (out_len < sizeof resp)
+ return -ENOSPC;
+
if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT;
@@ -2371,6 +2389,9 @@ ssize_t ib_uverbs_post_recv(struct ib_uverbs_file *file,
if (in_len < sizeof cmd)
return -EINVAL;
+ if (out_len < sizeof resp)
+ return -ENOSPC;
+
if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT;
@@ -2423,6 +2444,9 @@ ssize_t ib_uverbs_post_srq_recv(struct ib_uverbs_file *file,
if (in_len < sizeof cmd)
return -EINVAL;
+ if (out_len < sizeof resp)
+ return -ENOSPC;
+
if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT;
@@ -2975,6 +2999,9 @@ ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file,
if (in_len < sizeof cmd)
return -EINVAL;
+ if (out_len < sizeof resp)
+ return -ENOSPC;
+
if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT;
Makes uverbs functions check the length of the output buffer: this will prevent uverbs from writing past userspace provided buffer. Signed-off-by: Yann Droneaud <ydroneaud@opteya.com> Link: http://mid.gmane.org/cover.1376847403.git.ydroneaud@opteya.com --- drivers/infiniband/core/uverbs_cmd.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)