[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20181007090337.21037-4-leon@kernel.org>
Date: Sun, 7 Oct 2018 12:03:36 +0300
From: Leon Romanovsky <leon@...nel.org>
To: Doug Ledford <dledford@...hat.com>,
Jason Gunthorpe <jgg@...lanox.com>
Cc: Leon Romanovsky <leonro@...lanox.com>,
RDMA mailing list <linux-rdma@...r.kernel.org>,
Guy Levi <guyle@...lanox.com>,
Yonatan Cohen <yonatanc@...lanox.com>,
Saeed Mahameed <saeedm@...lanox.com>,
linux-netdev <netdev@...r.kernel.org>
Subject: [PATCH rdma-next 3/4] IB/mlx5: Verify that driver supports user flags
From: Yonatan Cohen <yonatanc@...lanox.com>
Flags sent down from user might not be supported by
running driver.
This might lead to unwanted bugs.
To solve this, added macro to test for unsupported flags.
Signed-off-by: Yonatan Cohen <yonatanc@...lanox.com>
Signed-off-by: Leon Romanovsky <leonro@...lanox.com>
---
drivers/infiniband/hw/mlx5/qp.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index bae48bdf281c..17c4b6641933 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -1728,6 +1728,15 @@ static void configure_requester_scat_cqe(struct mlx5_ib_dev *dev,
MLX5_SET(qpc, qpc, cs_req, MLX5_REQ_SCAT_DATA32_CQE);
}
+#define MLX5_QP_CREATE_FLAGS_NOT_SUPPORTED(flags) \
+ ((flags) & ~( \
+ MLX5_QP_FLAG_SIGNATURE | \
+ MLX5_QP_FLAG_SCATTER_CQE | \
+ MLX5_QP_FLAG_TUNNEL_OFFLOADS | \
+ MLX5_QP_FLAG_BFREG_INDEX | \
+ MLX5_QP_FLAG_TYPE_DCT | \
+ MLX5_QP_FLAG_TYPE_DCI))
+
static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd,
struct ib_qp_init_attr *init_attr,
struct ib_udata *udata, struct mlx5_ib_qp *qp)
@@ -1825,6 +1834,9 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd,
return -EFAULT;
}
+ if (MLX5_QP_CREATE_FLAGS_NOT_SUPPORTED(ucmd.flags))
+ return -EINVAL;
+
err = get_qp_user_index(to_mucontext(pd->uobject->context),
&ucmd, udata->inlen, &uidx);
if (err)
--
2.14.4
Powered by blists - more mailing lists