diff mbox

[rdma-next,v1] RDMA/mlx5: Fix definition of mlx5_ib_create_qp_resp

Message ID 20180403070053.31239-1-leon@kernel.org (mailing list archive)
State Accepted
Headers show

Commit Message

Leon Romanovsky April 3, 2018, 7 a.m. UTC
From: Jason Gunthorpe <jgg@mellanox.com>

This structure is pushed down the ex and the non-ex path, so it needs to be
aligned to 8 bytes to go through ex without implicit padding.

Old user space will provide 4 bytes of resp on !ex and 8 bytes on ex, so
take the approach of just copying the minimum length.

New user space will consistently provide 8 bytes in both cases.

Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 * Sent wrong patch in v0.
---
 drivers/infiniband/hw/mlx5/qp.c | 4 ++--
 include/uapi/rdma/mlx5-abi.h    | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

--
2.14.3

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Jason Gunthorpe April 3, 2018, 8:07 p.m. UTC | #1
On Tue, Apr 03, 2018 at 10:00:53AM +0300, Leon Romanovsky wrote:
> From: Jason Gunthorpe <jgg@mellanox.com>
> 
> This structure is pushed down the ex and the non-ex path, so it needs to be
> aligned to 8 bytes to go through ex without implicit padding.
> 
> Old user space will provide 4 bytes of resp on !ex and 8 bytes on ex, so
> take the approach of just copying the minimum length.
> 
> New user space will consistently provide 8 bytes in both cases.
> 
> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
> Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
> ---
>  * Sent wrong patch in v0.
> ---
>  drivers/infiniband/hw/mlx5/qp.c | 4 ++--
>  include/uapi/rdma/mlx5-abi.h    | 1 +
>  2 files changed, 3 insertions(+), 2 deletions(-)

Since this is part of a fixing a rdma-core regression I've taken it
right away into -next

Thanks,
Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index d4476d4e8a8b..0a0524f60924 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -880,7 +880,7 @@  static int create_user_qp(struct mlx5_ib_dev *dev, struct ib_pd *pd,
 		goto err_free;
 	}

-	err = ib_copy_to_udata(udata, resp, sizeof(*resp));
+	err = ib_copy_to_udata(udata, resp, min(udata->outlen, sizeof(*resp)));
 	if (err) {
 		mlx5_ib_dbg(dev, "copy failed\n");
 		goto err_unmap;
@@ -1469,7 +1469,7 @@  static int create_rss_raw_qp_tir(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
 		return -EOPNOTSUPP;
 	}

-	err = ib_copy_to_udata(udata, &resp, min_resp_len);
+	err = ib_copy_to_udata(udata, &resp, min(udata->outlen, sizeof(resp)));
 	if (err) {
 		mlx5_ib_dbg(dev, "copy failed\n");
 		return -EINVAL;
diff --git a/include/uapi/rdma/mlx5-abi.h b/include/uapi/rdma/mlx5-abi.h
index c0900f4800cf..cb4a02c4a1ce 100644
--- a/include/uapi/rdma/mlx5-abi.h
+++ b/include/uapi/rdma/mlx5-abi.h
@@ -344,6 +344,7 @@  struct mlx5_ib_create_qp_rss {

 struct mlx5_ib_create_qp_resp {
 	__u32	bfreg_index;
+	__u32   reserved;
 };

 struct mlx5_ib_alloc_mw {