Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5309551pxv; Wed, 21 Jul 2021 02:18:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdIIfk9pE78saW5fJSDaGi6PpwtdIXk5/Ip/IDz9uLYSB7c3G5t2KvvcOWBjcrG5u+M/DS X-Received: by 2002:a02:8783:: with SMTP id t3mr29909893jai.45.1626859130646; Wed, 21 Jul 2021 02:18:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626859130; cv=none; d=google.com; s=arc-20160816; b=Jpxejjj/tQCxPtH6MUOvn+kq/UVjQ1Ve3IBSfys2IG6pws+L0waxZuP5+MxwBjVLkv KM7h7rVe9O+3tgk4m52MDnnqHqeMtanTsjrwcCFjVBTGbPQhGMTm6jGSMbAOCIZem+BM cZd9pt+fCntQ+gDe9tNC1xc6Mxh/RrQs4d54kyqX7DfxpwFVbqDbDdgrw9DIQTCrUj45 6H7+d8p5zrbbEL0jgNCS3m9WGom+TNMYSGSY1cT32RtamHagFtFfF6KaQ8JTYgUoq0P3 lTVilh3Dl/Wg4OMkbgmBPM3nC2UVGkH9pshS2+1XnEwHSfDD2n0kHAja0N5qViyy3sf7 LtiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=aNwcEdGmINqRZWjwd/MwSaJoyttSRTtKBGscPinNcw0=; b=V8pAjzWCDvU34Qf1aHJV06gjhkSxfywf1Rbb+xZlzU+gC+R1OZWT/1lnlYns12Hspb lXx7tXjSLRS0hWxT/qM18G+4lPS0LJrzP7XjEAseQxIX9w17W33sToupwkXfNxuNsmuu u1H8u3/uShUQIxAsz807w5ioKh03uJuAmyUv2V/lsjX24oJRH7JRY0zybnNYetHFF0wH ye2YbWKro99G9Jy7GgJghZOiEmqT0tJin6fhbzG9KMAPaIcO+H72ApI52FiOTMbNICNO OyQJqEnpTdem0UMo1gx+TXmVQ4DhDqji61yo2o5o7Z7MoyinEccTKC4CqVX/zaS7Y0gG HIXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AbzPYXTB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d6si15581403ilm.75.2021.07.21.02.18.39; Wed, 21 Jul 2021 02:18:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AbzPYXTB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237745AbhGUIe6 (ORCPT + 99 others); Wed, 21 Jul 2021 04:34:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:56580 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236785AbhGUI1E (ORCPT ); Wed, 21 Jul 2021 04:27:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1566E6120C; Wed, 21 Jul 2021 09:07:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626858460; bh=jiCQfqGnLvlVni+94Cn3udgdJVPdHo0fDi0NpMPZUW8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AbzPYXTBSCIVroy/Ph22yeggOVTRabXdfZsTKauINANt/+iTz7Aup1frk1U8Cck7A xExOxsf0ekTnUHHhHSEAt0Dc4gaAFoCfUxTSgdDvZGLcErkfzx8/1x+RlUyY3EEIXZ JC/gEekXclb39NygU54fOheXk8q3tuobBXtLZjAQIZIN8XvMP/ThGmOPJow+wOlAFJ rbrb+qH9j6LzjXPsRjA2wbg9OAYytz3fq1q+bAlVaaHlF9KsqyX33ivwsRBA4yfO5g aJ24leaAzXGkpmbUyJJ/sqbdkGUbtL0k3LNvUUVhS5lx5PadJrQHTA2exOmiVAiX3y JYkb2pQ4vRBrA== From: Leon Romanovsky To: Doug Ledford , Jason Gunthorpe Cc: Leon Romanovsky , linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, Mark Zhang , Christoph Hellwig Subject: [PATCH rdma-next v1 5/7] RDMA/core: Configure selinux QP during creation Date: Wed, 21 Jul 2021 12:07:08 +0300 Message-Id: <4cb55670db663bcd45095dad67a59d7c2324e0b3.1626857976.git.leonro@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Leon Romanovsky 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 --- 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