From patchwork Thu Feb 15 20:36:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adit Ranadive X-Patchwork-Id: 10223513 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3E656602CB for ; Thu, 15 Feb 2018 20:37:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D45E285CD for ; Thu, 15 Feb 2018 20:37:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 209F4284AF; Thu, 15 Feb 2018 20:37:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6CA24285CD for ; Thu, 15 Feb 2018 20:37:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1033614AbeBOUhM (ORCPT ); Thu, 15 Feb 2018 15:37:12 -0500 Received: from mail-bl2nam02on0045.outbound.protection.outlook.com ([104.47.38.45]:12633 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1033595AbeBOUhL (ORCPT ); Thu, 15 Feb 2018 15:37:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=onevmw.onmicrosoft.com; s=selector1-vmware-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=X7n8k4x4DMaEka36RotIANqv9SpDOl5iUfvFm1pohug=; b=nI/3rLgcrSxAFXVqMDswjN48686ftHJlzRuwBJQrP3/4j72+YhPhF4Xqgq8asFEQ/dhVCak8uoON6WNlp3Hzun+EsZ44lqHyhEl8m2NxqTE80WqhQYyX1dKZZtPdH9c3cbVCYaY5M0ntuITMf4HjQqIi0+Md5lNdxhphbAIpGLw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=aditr@vmware.com; Received: from promb-2s-dhcp95-136.eng.vmware.com (208.91.1.34) by BN1PR05MB486.namprd05.prod.outlook.com (2a01:111:e400:31::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.527.6; Thu, 15 Feb 2018 20:37:07 +0000 From: Adit Ranadive To: dledford@redhat.com, jgg@mellanox.com, linux-rdma@vger.kernel.org Cc: Adit Ranadive , pv-drivers@vmware.com Subject: [PATCH rdma-rc] RDMA/vmw_pvrdma: Fix usage of user response structures in ABI file Date: Thu, 15 Feb 2018 12:36:46 -0800 Message-Id: <1518727006-4073-1-git-send-email-aditr@vmware.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [208.91.1.34] X-ClientProxiedBy: AM5PR0202CA0022.eurprd02.prod.outlook.com (2603:10a6:203:69::32) To BN1PR05MB486.namprd05.prod.outlook.com (2a01:111:e400:31::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bae209c4-43fb-42f0-3247-08d574b3e26f X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:BN1PR05MB486; X-Microsoft-Exchange-Diagnostics: 1; BN1PR05MB486; 3:9mPZZ0ze6OwRbhhm1Tr2OT8zJrZcjeEflMp+TWfPRr+RZQ6lbZKVEiMb3c7GMN+kR3HqJQSInc+U/NWlw4G4qdqL+lXUyx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ijJXec12Nmz2ORgSSluiXGGij8k1uXKzIuNEF5sMeoQMSBKloKsPHmVTugeE4Z5dMbwQ2G55sSTbZ2Rd0XoaAzFBOVKRBGbZ1akkdmVS8erXdFupya8WGKr4+j33DwE9+daFE0e+QWdjywMrX1N7djKvSlvj6zR0bAJV87wy2llNENn3P2Na/hFMJ5kzWn+mnf+KiwIU8mgV/JOHx3bpplqFuTwxm5EwfFfm34qNd9vP1RBd9VWfOYDtG+vAQuFz3JWuoNuhMyvIVQ3LxiQ3EuDXOuNrtRUrh8H1uBiaNaicr2u; 4:m9wLa04puQuYitqvjyrd4TrObQvF3cM0hT79vuMFD5tCGRU4P46EY0/bBTos6o3gvYMC+tBlaKZlOospO+JutuFA0WBKpUFCf4LZ1i2c/tgO9IIx5pQO3c3YV5/qDQLzgPd7udoscCqC6DUQU/6J7dzHOQUdQf6wOSMqtP9mLe/q5Hndb3T50Q2LElTbBQAWiByIyjAL9sgRrWOrjwzLfZnyUgg33bf0ar4kVkA+8it+SMVEE0AZdHV3PZ6GhEu0Q2ajMGTMyejedoKpJv1t6w79Tv4xlvRikjgtYa7xngGRXbdlnfXHEQh7ZJXGe2L5 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(61668805478150); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(5005006)(8121501046)(3231101)(944501161)(93006095)(93001095)(10201501046)(3002001)(6041288)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(6072148)(201708071742011); SRVR:BN1PR05MB486; BCL:0; PCL:0; RULEID:; SRVR:BN1PR05MB486; X-Forefront-PRVS: 058441C12A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(39380400002)(376002)(346002)(396003)(39860400002)(189003)(199004)(48376002)(107886003)(50226002)(4326008)(6486002)(6666003)(8676002)(8936002)(68736007)(106356001)(53936002)(81156014)(81166006)(478600001)(105586002)(316002)(2906002)(5660300001)(25786009)(97736004)(16526019)(51416003)(16586007)(52116002)(7736002)(7696005)(305945005)(386003)(59450400001)(26005)(186003)(6116002)(3846002)(36756003)(66066001)(86362001)(50466002)(47776003); DIR:OUT; SFP:1101; SCL:1; SRVR:BN1PR05MB486; H:promb-2s-dhcp95-136.eng.vmware.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: vmware.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN1PR05MB486; 23:NC55DuR7MjEoRjHH9tsf1vuGpbGfGbp+G9FevffRK/?= =?us-ascii?Q?9jzwjdC2m3IVoOIz6ueV4gnzKhl1LtP0C+avG3UsLiWtNb9liAE55tY5QZdT?= =?us-ascii?Q?f2HD8im956BW5uIr+PM/RzLjk5K6MpcvlzbJGhGUQr4x8FZLUms9Y+gZCPkr?= =?us-ascii?Q?qSKNEw97VPVNHGa/PpOX4VEB3RtuEgbC2HBRNDLpS3P0kmymWw8xloCr7eCX?= =?us-ascii?Q?4XneWsfXaTs8BB9orUVP+akDxW14rymxPIjhQ2RuN/TBI/9vCGhuZ6DFiRoZ?= =?us-ascii?Q?PRUFWtq4YlYGvgYRppemIhh+Zu8CuLcbF/0jzSr634EvgLO61tT7u02ygvzk?= =?us-ascii?Q?36ltlXG5F6nWQ6acInda0NzkJcCdX/wpoH28h3ZuRwqm+V3J5/JD2r+0cIa2?= =?us-ascii?Q?ZjsVhcNTg42ZFkwG0m3a348KX4X8M0g2NwifsuzwuXFqjpMX/Gph4LElxM53?= =?us-ascii?Q?mbB63kAAWPDRWTxU8AT9KP8Th9kQREwJoLK14ICH7tAorEfzALGFO7JnpOY9?= =?us-ascii?Q?M6K0HHjgxuJXJIJoVzdDjuS4+DuBIvp0MaqLjfBIyLkx1Z8aQhKTqMUguWuQ?= =?us-ascii?Q?LQT6JRR64omSmmMjQwTgq/GQ+fHDwbYxtxzK3KTrm6y8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VNsaR3ELQA/rxxa0Tpo3S09sZAYLxfmhLd3BsMVBawI+ZLGo+YTtaQRJIbcKn4pyZo0+itI=; 24:B4k4U2B+PS1KT91w7w4jB2UdFH8xdfJRjpDWc+ecXiYFBZ8W7oONvnNOSXKju8swbX0TCp+FITppO4tAF4d/uZyQUoPqStCWQTapDyNxBDw=; 7:p7KTC97BtZuF6kmJV1We/KmotZlpD2rjgb+vY9jX8ojTwhYD+5df9LrDfXZllhI9pPxV6kShVCu4hTdlspk3kKhyxNuqehNdBLJmhc4BfRk58vuKLl0S/zv+Ij7JfaQSpCwohoHTT4dCa9lcM/diUXE1t7mTnQ9IxhYFbdLJM/jdCNaDyMyonCFFVYZDQpETq8sp68J/UZ64ZFmf6c/U/2CdLpZWJ8BdX0gtvkW4DhrfRiCLJwLGiW4l+NTo2/ND SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN1PR05MB486; 20:zLN6501dHH5SNYl7yJKyOAJ0iBdNQVspkk5SQ2MuNxNJgEVPZeFEm/QQ2JKRK4Ak4+YXgT1O0+qfqiYrflzFmcZG9JISa/y4sH90adkZqNpqovlsLD2hW3+b0jafOTqJ30pqZS9EZSM0zkZ5H17/QN5I92isxA4LBZDM+6hppbU= X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2018 20:37:07.2980 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bae209c4-43fb-42f0-3247-08d574b3e26f X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN1PR05MB486 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Doug, Jason, Here is a patch for the vmw_pvrdma driver for the 4.16 RC. Thanks, Adit --- This ensures that we return the right structures back to userspace. Otherwise, it looks like the reserved fields in the response structures in userspace might have uninitialized data in them. Fixes: 8b10ba783c9d ("RDMA/vmw_pvrdma: Add shared receive queue support") Fixes: 29c8d9eba550 ("IB: Add vmw_pvrdma driver") Suggested-by: Jason Gunthorpe Reviewed-by: Bryan Tan Reviewed-by: Aditya Sarwade Reviewed-by: Jorgen Hansen Signed-off-by: Adit Ranadive --- drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c | 4 +++- drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c | 4 +++- drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.c | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c index faa9478..f95b976 100644 --- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c @@ -114,6 +114,7 @@ struct ib_cq *pvrdma_create_cq(struct ib_device *ibdev, union pvrdma_cmd_resp rsp; struct pvrdma_cmd_create_cq *cmd = &req.create_cq; struct pvrdma_cmd_create_cq_resp *resp = &rsp.create_cq_resp; + struct pvrdma_create_cq_resp cq_resp = {0}; struct pvrdma_create_cq ucmd; BUILD_BUG_ON(sizeof(struct pvrdma_cqe) != 64); @@ -197,6 +198,7 @@ struct ib_cq *pvrdma_create_cq(struct ib_device *ibdev, cq->ibcq.cqe = resp->cqe; cq->cq_handle = resp->cq_handle; + cq_resp.cqn = resp->cq_handle; spin_lock_irqsave(&dev->cq_tbl_lock, flags); dev->cq_tbl[cq->cq_handle % dev->dsr->caps.max_cq] = cq; spin_unlock_irqrestore(&dev->cq_tbl_lock, flags); @@ -205,7 +207,7 @@ struct ib_cq *pvrdma_create_cq(struct ib_device *ibdev, cq->uar = &(to_vucontext(context)->uar); /* Copy udata back. */ - if (ib_copy_to_udata(udata, &cq->cq_handle, sizeof(__u32))) { + if (ib_copy_to_udata(udata, &cq_resp, sizeof(cq_resp))) { dev_warn(&dev->pdev->dev, "failed to copy back udata\n"); pvrdma_destroy_cq(&cq->ibcq); diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c index 5acebb1..af23596 100644 --- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_srq.c @@ -113,6 +113,7 @@ struct ib_srq *pvrdma_create_srq(struct ib_pd *pd, union pvrdma_cmd_resp rsp; struct pvrdma_cmd_create_srq *cmd = &req.create_srq; struct pvrdma_cmd_create_srq_resp *resp = &rsp.create_srq_resp; + struct pvrdma_create_srq_resp srq_resp = {0}; struct pvrdma_create_srq ucmd; unsigned long flags; int ret; @@ -204,12 +205,13 @@ struct ib_srq *pvrdma_create_srq(struct ib_pd *pd, } srq->srq_handle = resp->srqn; + srq_resp.srqn = resp->srqn; spin_lock_irqsave(&dev->srq_tbl_lock, flags); dev->srq_tbl[srq->srq_handle % dev->dsr->caps.max_srq] = srq; spin_unlock_irqrestore(&dev->srq_tbl_lock, flags); /* Copy udata back. */ - if (ib_copy_to_udata(udata, &srq->srq_handle, sizeof(__u32))) { + if (ib_copy_to_udata(udata, &srq_resp, sizeof(srq_resp))) { dev_warn(&dev->pdev->dev, "failed to copy back udata\n"); pvrdma_destroy_srq(&srq->ibsrq); return ERR_PTR(-EINVAL); diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.c index 16b9661..a51463c 100644 --- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.c +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.c @@ -447,6 +447,7 @@ struct ib_pd *pvrdma_alloc_pd(struct ib_device *ibdev, union pvrdma_cmd_resp rsp; struct pvrdma_cmd_create_pd *cmd = &req.create_pd; struct pvrdma_cmd_create_pd_resp *resp = &rsp.create_pd_resp; + struct pvrdma_alloc_pd_resp pd_resp = {0}; int ret; void *ptr; @@ -475,9 +476,10 @@ struct ib_pd *pvrdma_alloc_pd(struct ib_device *ibdev, pd->privileged = !context; pd->pd_handle = resp->pd_handle; pd->pdn = resp->pd_handle; + pd_resp.pdn = resp->pd_handle; if (context) { - if (ib_copy_to_udata(udata, &pd->pdn, sizeof(__u32))) { + if (ib_copy_to_udata(udata, &pd_resp, sizeof(pd_resp))) { dev_warn(&dev->pdev->dev, "failed to copy back protection domain\n"); pvrdma_dealloc_pd(&pd->ibpd);