Commit 1c407cb5 authored by Jason Gunthorpe's avatar Jason Gunthorpe
Browse files

RDMA: Check flags during create_cq

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: 41b2a71f ("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: default avatarJason Gunthorpe <jgg@nvidia.com>
parent 26e990ba
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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) |
+3 −0
Original line number Diff line number Diff line
@@ -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");
+1 −1
Original line number Diff line number Diff line
@@ -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;
+3 −0
Original line number Diff line number Diff line
@@ -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",
+3 −0
Original line number Diff line number Diff line
@@ -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);
Loading