From: Leon Romanovsky <leon@kernel.org>
To: Doug Ledford <dledford@redhat.com>, Jason Gunthorpe <jgg@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>,
linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org,
Mark Zhang <markz@mellanox.com>,
Christoph Hellwig <hch@infradead.org>
Subject: [PATCH rdma-next v1 5/7] RDMA/core: Configure selinux QP during creation
Date: Wed, 21 Jul 2021 12:07:08 +0300 [thread overview]
Message-ID: <4cb55670db663bcd45095dad67a59d7c2324e0b3.1626857976.git.leonro@nvidia.com> (raw)
In-Reply-To: <cover.1626857976.git.leonro@nvidia.com>
From: Leon Romanovsky <leonro@nvidia.com>
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.
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
drivers/infiniband/core/uverbs_cmd.c | 7 -------
drivers/infiniband/core/uverbs_std_types_qp.c | 6 ------
drivers/infiniband/core/verbs.c | 11 +++++++----
3 files changed, 7 insertions(+), 17 deletions(-)
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index 8c8ca7bce3ca..b5153200b8a8 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -1447,10 +1447,6 @@ static int create_qp(struct uverbs_attr_bundle *attrs,
}
if (cmd->qp_type != IB_QPT_XRC_TGT) {
- ret = ib_create_qp_security(qp, device);
- if (ret)
- goto err_cb;
-
atomic_inc(&pd->usecnt);
if (attr.send_cq)
atomic_inc(&attr.send_cq->usecnt);
@@ -1502,9 +1498,6 @@ static int create_qp(struct uverbs_attr_bundle *attrs,
resp.response_length = uverbs_response_length(attrs, sizeof(resp));
return uverbs_response(attrs, &resp, sizeof(resp));
-err_cb:
- ib_destroy_qp_user(qp, uverbs_get_cleared_udata(attrs));
-
err_put:
if (!IS_ERR(xrcd_uobj))
uobj_put_read(xrcd_uobj);
diff --git a/drivers/infiniband/core/uverbs_std_types_qp.c b/drivers/infiniband/core/uverbs_std_types_qp.c
index c00cfb5ed387..92812f6a21b0 100644
--- a/drivers/infiniband/core/uverbs_std_types_qp.c
+++ b/drivers/infiniband/core/uverbs_std_types_qp.c
@@ -280,12 +280,6 @@ static int UVERBS_HANDLER(UVERBS_METHOD_QP_CREATE)(
obj->uevent.uobject.object = qp;
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);
ret = uverbs_copy_to_struct_or_zero(attrs,
UVERBS_ATTR_CREATE_QP_RESP_CAP, &cap,
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index 7ee4daa72934..9f6f7df55c9a 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -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,
const char *caller)
{
+ struct ib_udata dummy = {};
struct ib_qp *qp;
int ret;
@@ -1257,9 +1258,15 @@ struct ib_qp *_ib_create_qp(struct ib_device *dev, struct ib_pd *pd,
qp->send_cq = attr->send_cq;
qp->recv_cq = attr->recv_cq;
+ ret = ib_create_qp_security(qp, dev);
+ if (ret)
+ goto err_security;
+
rdma_restrack_add(&qp->res);
return qp;
+err_security:
+ qp->device->ops.destroy_qp(qp, udata ? &dummy : NULL);
err_create:
rdma_restrack_put(&qp->res);
kfree(qp);
@@ -1289,10 +1296,6 @@ struct ib_qp *ib_create_qp_kernel(struct ib_pd *pd,
if (IS_ERR(qp))
return qp;
- ret = ib_create_qp_security(qp, device);
- if (ret)
- goto err;
-
if (qp_init_attr->qp_type == IB_QPT_XRC_TGT) {
struct ib_qp *xrc_qp =
create_xrc_qp_user(qp, qp_init_attr);
--
2.31.1
next prev parent reply other threads:[~2021-07-21 9:23 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-21 9:07 [PATCH rdma-next v1 0/7] Separate user/kernel QP creation logic Leon Romanovsky
2021-07-21 9:07 ` [PATCH rdma-next v1 1/7] RDMA/mlx5: Delete not-available udata check Leon Romanovsky
2021-07-21 9:07 ` [PATCH rdma-next v1 2/7] RDMA/core: Delete duplicated and unreachable code Leon Romanovsky
2021-07-21 9:07 ` [PATCH rdma-next v1 3/7] RDMA/core: Remove protection from wrong in-kernel API usage Leon Romanovsky
2021-07-21 9:07 ` [PATCH rdma-next v1 4/7] RDMA/core: Reorganize create QP low-level functions Leon Romanovsky
2021-07-21 9:07 ` Leon Romanovsky [this message]
2021-07-21 9:07 ` [PATCH rdma-next v1 6/7] RDMA/core: Properly increment and decrement QP usecnts Leon Romanovsky
2021-07-21 9:07 ` [PATCH rdma-next v1 7/7] RDMA/core: Create clean QP creations interface for uverbs Leon Romanovsky
2021-08-03 18:10 ` [PATCH rdma-next v1 0/7] Separate user/kernel QP creation logic Leon Romanovsky
2021-08-03 18:13 ` Jason Gunthorpe
2021-08-03 18:17 ` Leon Romanovsky
2021-08-03 18:21 ` Leon Romanovsky
2021-08-03 18:26 ` Jason Gunthorpe
2021-08-03 23:33 ` Jason Gunthorpe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4cb55670db663bcd45095dad67a59d7c2324e0b3.1626857976.git.leonro@nvidia.com \
--to=leon@kernel.org \
--cc=dledford@redhat.com \
--cc=hch@infradead.org \
--cc=jgg@nvidia.com \
--cc=leonro@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=markz@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).