Commit 00a79d6b authored by Leon Romanovsky's avatar Leon Romanovsky Committed by Jason Gunthorpe

RDMA/core: Configure selinux QP during creation

All QP creation flows called ib_create_qp_security(), but differently.
This caused to the need to provide exclusion conditions for the XRC_TGT,
because such QP already had selinux configuration call.

In order to fix it, move ib_create_qp_security() to the general QP
creation routine.

Link: https://lore.kernel.org/r/4d7cd6f5828aca37fb62283e6b126b73ab86b18c.1628014762.git.leonro@nvidia.comSigned-off-by: default avatarLeon Romanovsky <leonro@nvidia.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
parent 8da9fe4e
...@@ -1447,10 +1447,6 @@ static int create_qp(struct uverbs_attr_bundle *attrs, ...@@ -1447,10 +1447,6 @@ static int create_qp(struct uverbs_attr_bundle *attrs,
} }
if (cmd->qp_type != IB_QPT_XRC_TGT) { if (cmd->qp_type != IB_QPT_XRC_TGT) {
ret = ib_create_qp_security(qp, device);
if (ret)
goto err_cb;
atomic_inc(&pd->usecnt); atomic_inc(&pd->usecnt);
if (attr.send_cq) if (attr.send_cq)
atomic_inc(&attr.send_cq->usecnt); atomic_inc(&attr.send_cq->usecnt);
...@@ -1502,9 +1498,6 @@ static int create_qp(struct uverbs_attr_bundle *attrs, ...@@ -1502,9 +1498,6 @@ static int create_qp(struct uverbs_attr_bundle *attrs,
resp.response_length = uverbs_response_length(attrs, sizeof(resp)); resp.response_length = uverbs_response_length(attrs, sizeof(resp));
return uverbs_response(attrs, &resp, sizeof(resp)); return uverbs_response(attrs, &resp, sizeof(resp));
err_cb:
ib_destroy_qp_user(qp, uverbs_get_cleared_udata(attrs));
err_put: err_put:
if (!IS_ERR(xrcd_uobj)) if (!IS_ERR(xrcd_uobj))
uobj_put_read(xrcd_uobj); uobj_put_read(xrcd_uobj);
......
...@@ -280,12 +280,6 @@ static int UVERBS_HANDLER(UVERBS_METHOD_QP_CREATE)( ...@@ -280,12 +280,6 @@ static int UVERBS_HANDLER(UVERBS_METHOD_QP_CREATE)(
obj->uevent.uobject.object = qp; obj->uevent.uobject.object = qp;
uverbs_finalize_uobj_create(attrs, UVERBS_ATTR_CREATE_QP_HANDLE); uverbs_finalize_uobj_create(attrs, UVERBS_ATTR_CREATE_QP_HANDLE);
if (attr.qp_type != IB_QPT_XRC_TGT) {
ret = ib_create_qp_security(qp, device);
if (ret)
return ret;
}
set_caps(&attr, &cap, false); set_caps(&attr, &cap, false);
ret = uverbs_copy_to_struct_or_zero(attrs, ret = uverbs_copy_to_struct_or_zero(attrs,
UVERBS_ATTR_CREATE_QP_RESP_CAP, &cap, UVERBS_ATTR_CREATE_QP_RESP_CAP, &cap,
......
...@@ -1216,6 +1216,7 @@ struct ib_qp *_ib_create_qp(struct ib_device *dev, struct ib_pd *pd, ...@@ -1216,6 +1216,7 @@ struct ib_qp *_ib_create_qp(struct ib_device *dev, struct ib_pd *pd,
struct ib_udata *udata, struct ib_uqp_object *uobj, struct ib_udata *udata, struct ib_uqp_object *uobj,
const char *caller) const char *caller)
{ {
struct ib_udata dummy = {};
struct ib_qp *qp; struct ib_qp *qp;
int ret; int ret;
...@@ -1256,9 +1257,15 @@ struct ib_qp *_ib_create_qp(struct ib_device *dev, struct ib_pd *pd, ...@@ -1256,9 +1257,15 @@ struct ib_qp *_ib_create_qp(struct ib_device *dev, struct ib_pd *pd,
qp->send_cq = attr->send_cq; qp->send_cq = attr->send_cq;
qp->recv_cq = attr->recv_cq; qp->recv_cq = attr->recv_cq;
ret = ib_create_qp_security(qp, dev);
if (ret)
goto err_security;
rdma_restrack_add(&qp->res); rdma_restrack_add(&qp->res);
return qp; return qp;
err_security:
qp->device->ops.destroy_qp(qp, udata ? &dummy : NULL);
err_create: err_create:
rdma_restrack_put(&qp->res); rdma_restrack_put(&qp->res);
kfree(qp); kfree(qp);
...@@ -1288,10 +1295,6 @@ struct ib_qp *ib_create_qp_kernel(struct ib_pd *pd, ...@@ -1288,10 +1295,6 @@ struct ib_qp *ib_create_qp_kernel(struct ib_pd *pd,
if (IS_ERR(qp)) if (IS_ERR(qp))
return qp; return qp;
ret = ib_create_qp_security(qp, device);
if (ret)
goto err;
if (qp_init_attr->qp_type == IB_QPT_XRC_TGT) { if (qp_init_attr->qp_type == IB_QPT_XRC_TGT) {
struct ib_qp *xrc_qp = struct ib_qp *xrc_qp =
create_xrc_qp_user(qp, qp_init_attr); create_xrc_qp_user(qp, qp_init_attr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment