RDMA: Check flags during create_cq
authorJason Gunthorpe <jgg@nvidia.com>
Sat, 3 Oct 2020 23:20:07 +0000 (20:20 -0300)
committerJason Gunthorpe <jgg@nvidia.com>
Mon, 26 Oct 2020 22:27:59 +0000 (19:27 -0300)
Each driver should check that the CQ attrs is supported. Unfortuantely
when flags was added to the CQ attrs the drivers were not updated,
uverbs_ex_cmd_mask was used to block it. This was missed when create CQ
was converted to ioctl, so non-zero flags could have been passed into
drivers.

Check that flags is zero in all drivers that don't use it, remove
IB_USER_VERBS_EX_CMD_CREATE_CQ from uverbs_ex_cmd_mask.

Fixes: 41b2a71fc848 ("IB/uverbs: Move ioctl path of create_cq and destroy_cq to a new file")
Link: https://lore.kernel.org/r/7-v1-caa70ba3d1ab+1436e-ucmd_mask_jgg@nvidia.com
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
16 files changed:
drivers/infiniband/core/device.c
drivers/infiniband/hw/bnxt_re/ib_verbs.c
drivers/infiniband/hw/cxgb4/cq.c
drivers/infiniband/hw/efa/efa_verbs.c
drivers/infiniband/hw/hns/hns_roce_cq.c
drivers/infiniband/hw/i40iw/i40iw_verbs.c
drivers/infiniband/hw/mlx4/main.c
drivers/infiniband/hw/mlx5/main.c
drivers/infiniband/hw/mthca/mthca_provider.c
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
drivers/infiniband/hw/qedr/verbs.c
drivers/infiniband/hw/usnic/usnic_ib_verbs.c
drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c
drivers/infiniband/sw/rdmavt/cq.c
drivers/infiniband/sw/rxe/rxe_verbs.c
drivers/infiniband/sw/siw/siw_verbs.c

index 6d26035..6412964 100644 (file)
@@ -632,6 +632,7 @@ struct ib_device *_ib_alloc_device(size_t size)
                BIT_ULL(IB_USER_VERBS_CMD_RESIZE_CQ);
 
        device->uverbs_ex_cmd_mask =
+               BIT_ULL(IB_USER_VERBS_EX_CMD_CREATE_CQ) |
                BIT_ULL(IB_USER_VERBS_EX_CMD_CREATE_FLOW) |
                BIT_ULL(IB_USER_VERBS_EX_CMD_CREATE_RWQ_IND_TBL) |
                BIT_ULL(IB_USER_VERBS_EX_CMD_CREATE_WQ) |
index f3ec6d3..edc4709 100644 (file)
@@ -2831,6 +2831,9 @@ int bnxt_re_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
        struct bnxt_qplib_nq *nq = NULL;
        unsigned int nq_alloc_cnt;
 
+       if (attr->flags)
+               return -EOPNOTSUPP;
+
        /* Validate CQ fields */
        if (cqe < 1 || cqe > dev_attr->max_cq_wqes) {
                ibdev_err(&rdev->ibdev, "Failed to create CQ -max exceeded");
index 28349ed..2cb65be 100644 (file)
@@ -1006,7 +1006,7 @@ int c4iw_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
 
        pr_debug("ib_dev %p entries %d\n", ibdev, entries);
        if (attr->flags)
-               return -EINVAL;
+               return -EOPNOTSUPP;
 
        if (vector >= rhp->rdev.lldi.nciq)
                return -EINVAL;
index e3d9a5a..2fe5708 100644 (file)
@@ -1032,6 +1032,9 @@ int efa_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
 
        ibdev_dbg(ibdev, "create_cq entries %d\n", entries);
 
+       if (attr->flags)
+               return -EOPNOTSUPP;
+
        if (entries < 1 || entries > dev->dev_attr.max_cq_depth) {
                ibdev_dbg(ibdev,
                          "cq: requested entries[%u] non-positive or greater than max[%u]\n",
index 809b22a..68f355f 100644 (file)
@@ -251,6 +251,9 @@ int hns_roce_create_cq(struct ib_cq *ib_cq, const struct ib_cq_init_attr *attr,
        u32 cq_entries = attr->cqe;
        int ret;
 
+       if (attr->flags)
+               return -EOPNOTSUPP;
+
        if (cq_entries < 1 || cq_entries > hr_dev->caps.max_cqes) {
                ibdev_err(ibdev, "Failed to check CQ count %d max=%d\n",
                          cq_entries, hr_dev->caps.max_cqes);
index acc5e94..f3eb60b 100644 (file)
@@ -1107,6 +1107,9 @@ static int i40iw_create_cq(struct ib_cq *ibcq,
        int err_code;
        int entries = attr->cqe;
 
+       if (attr->flags)
+               return -EOPNOTSUPP;
+
        if (iwdev->closing)
                return -ENODEV;
 
index 355c826..c2c66b9 100644 (file)
@@ -2659,7 +2659,6 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 
        ib_set_device_ops(&ibdev->ib_dev, &mlx4_ib_dev_ops);
        ibdev->ib_dev.uverbs_ex_cmd_mask |=
-               (1ull << IB_USER_VERBS_EX_CMD_CREATE_CQ) |
                (1ull << IB_USER_VERBS_EX_CMD_CREATE_QP);
 
        if ((dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_RSS) &&
index b9a12a1..261cc66 100644 (file)
@@ -4143,7 +4143,6 @@ static int mlx5_ib_stage_caps_init(struct mlx5_ib_dev *dev)
                (1ull << IB_USER_VERBS_CMD_CREATE_AH)           |
                (1ull << IB_USER_VERBS_CMD_DESTROY_AH);
        dev->ib_dev.uverbs_ex_cmd_mask |=
-               (1ull << IB_USER_VERBS_EX_CMD_CREATE_CQ)        |
                (1ull << IB_USER_VERBS_EX_CMD_CREATE_QP);
 
        if (MLX5_CAP_GEN(mdev, ipoib_enhanced_offloads) &&
index ea4a8de..e37c965 100644 (file)
@@ -612,7 +612,7 @@ static int mthca_create_cq(struct ib_cq *ibcq,
                udata, struct mthca_ucontext, ibucontext);
 
        if (attr->flags)
-               return -EINVAL;
+               return -EOPNOTSUPP;
 
        if (entries < 1 || entries > to_mdev(ibdev)->limits.max_cqes)
                return -EINVAL;
index 244dd22..29ec0a8 100644 (file)
@@ -974,7 +974,7 @@ int ocrdma_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
        struct ocrdma_create_cq_ureq ureq;
 
        if (attr->flags)
-               return -EINVAL;
+               return -EOPNOTSUPP;
 
        if (udata) {
                if (ib_copy_from_udata(&ureq, udata, sizeof(ureq)))
index 34c07a1..8037317 100644 (file)
@@ -928,6 +928,9 @@ int qedr_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
                 "create_cq: called from %s. entries=%d, vector=%d\n",
                 udata ? "User Lib" : "Kernel", entries, vector);
 
+       if (attr->flags)
+               return -EOPNOTSUPP;
+
        if (entries > QEDR_MAX_CQES) {
                DP_ERR(dev,
                       "create cq: the number of entries %d is too high. Must be equal or below %d.\n",
index a89d581..d6708d1 100644 (file)
@@ -584,7 +584,7 @@ int usnic_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
                       struct ib_udata *udata)
 {
        if (attr->flags)
-               return -EINVAL;
+               return -EOPNOTSUPP;
 
        return 0;
 }
index 319546a..a119ac3 100644 (file)
@@ -119,6 +119,9 @@ int pvrdma_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
 
        BUILD_BUG_ON(sizeof(struct pvrdma_cqe) != 64);
 
+       if (attr->flags)
+               return -EOPNOTSUPP;
+
        entries = roundup_pow_of_two(entries);
        if (entries < 1 || entries > dev->dsr->caps.max_cqe)
                return -EINVAL;
index 19248be..20cc079 100644 (file)
@@ -211,7 +211,7 @@ int rvt_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
        int err;
 
        if (attr->flags)
-               return -EINVAL;
+               return -EOPNOTSUPP;
 
        if (entries < 1 || entries > rdi->dparms.props.max_cqe)
                return -EINVAL;
index dafcc03..7d32cb2 100644 (file)
@@ -771,7 +771,7 @@ static int rxe_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
        }
 
        if (attr->flags)
-               return -EINVAL;
+               return -EOPNOTSUPP;
 
        err = rxe_cq_chk_attr(rxe, NULL, attr->cqe, attr->comp_vector);
        if (err)
index 947b8b1..bcea5c5 100644 (file)
@@ -1097,6 +1097,9 @@ int siw_create_cq(struct ib_cq *base_cq, const struct ib_cq_init_attr *attr,
        struct siw_cq *cq = to_siw_cq(base_cq);
        int rv, size = attr->cqe;
 
+       if (attr->flags)
+               return -EOPNOTSUPP;
+
        if (atomic_inc_return(&sdev->num_cq) > SIW_MAX_CQ) {
                siw_dbg(base_cq->device, "too many CQ's\n");
                rv = -ENOMEM;