From patchwork Sun Oct 7 08:08:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shamir Rabinovitch X-Patchwork-Id: 10629389 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 81CC3174A for ; Sun, 7 Oct 2018 08:08:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 743AB29193 for ; Sun, 7 Oct 2018 08:08:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 681F9291A0; Sun, 7 Oct 2018 08:08:54 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY 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 B490F29193 for ; Sun, 7 Oct 2018 08:08:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727686AbeJGPPT (ORCPT ); Sun, 7 Oct 2018 11:15:19 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:49990 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726427AbeJGPPT (ORCPT ); Sun, 7 Oct 2018 11:15:19 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w97847pW181967; Sun, 7 Oct 2018 08:08:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=XzJ/7MLtmvZVpV6iCQcQxKLmweYgb8MEzIP5Wt/jNd8=; b=d74g2gXrEnGLLjz/jy2OyWGVhiY0iv2ze/21nJ9TY/X6+L+HvXPLd6eD/1Q2kLoiWLa4 PzwHyfjGTAymHdSETQbmhITnGcGoXlwHmi9ZCS5ZNAgkswQoBu8d5culBIY5oz9fdW6a Yx44DNpLlb6JadD9FpDC7Vnpz21bpO252Dt1T5hvYLIVgY2q9c3N/9yLWIOipRKa+cnX Mso78Qsd9EG3StjBskT3XYPnA9Mt5y3pNihdKMQDThOY9KHVC8ql/XOU2BtpYQX5/xHr kEIalipQZkGNPgvqPlcealbSxx/DXNE8K+qAK5qtUVed7WTLE+KBHy+wvDie527AqzKF kw== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2mxnpqj3ew-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 07 Oct 2018 08:08:47 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9788kvF032285 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 7 Oct 2018 08:08:46 GMT Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9788j8j026474; Sun, 7 Oct 2018 08:08:45 GMT Received: from localhost.localdomain (/10.175.55.174) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 07 Oct 2018 08:08:44 +0000 From: Shamir Rabinovitch To: linux-rdma@vger.kernel.org Cc: dledford@redhat.com, jgg@ziepe.ca, leon@kernel.org, santosh.shilimkar@oracle.com, shamir.rabinovitch@oracle.com Subject: [PATCH 2/7] IB/uverbs: initialize context field in ib_udata Date: Sun, 7 Oct 2018 11:08:15 +0300 Message-Id: <20181007080820.2571-3-shamir.rabinovitch@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181007080820.2571-1-shamir.rabinovitch@oracle.com> References: <20181007080820.2571-1-shamir.rabinovitch@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9038 signatures=668706 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810070086 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 initialize the context field in ib_udata created from uverbs commands and extended commands path. Signed-off-by: Shamir Rabinovitch --- drivers/infiniband/core/uverbs.h | 17 ++++++++------ drivers/infiniband/core/uverbs_cmd.c | 34 +++++++++++++-------------- drivers/infiniband/core/uverbs_main.c | 6 +++-- 3 files changed, 31 insertions(+), 26 deletions(-) diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h index c97935a0c7c6..7c6c2c975125 100644 --- a/drivers/infiniband/core/uverbs.h +++ b/drivers/infiniband/core/uverbs.h @@ -55,23 +55,26 @@ static inline void ib_uverbs_init_udata(struct ib_udata *udata, const void __user *ibuf, void __user *obuf, - size_t ilen, size_t olen) + size_t ilen, size_t olen, + struct ib_ucontext *context) { - udata->inbuf = ibuf; - udata->outbuf = obuf; - udata->inlen = ilen; - udata->outlen = olen; + udata->inbuf = ibuf; + udata->outbuf = obuf; + udata->inlen = ilen; + udata->outlen = olen; + udata->context = context; } static inline void ib_uverbs_init_udata_buf_or_null(struct ib_udata *udata, const void __user *ibuf, void __user *obuf, - size_t ilen, size_t olen) + size_t ilen, size_t olen, + struct ib_ucontext *context) { ib_uverbs_init_udata(udata, ilen ? ibuf : NULL, olen ? obuf : NULL, - ilen, olen); + ilen, olen, context); } /* diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index ef83813aefc2..c464ed65cbbb 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -100,7 +100,7 @@ ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file, ib_uverbs_init_udata(&udata, buf + sizeof(cmd), u64_to_user_ptr(cmd.response) + sizeof(resp), in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr), - out_len - sizeof(resp)); + out_len - sizeof(resp), file->ucontext); ret = ib_rdmacg_try_charge(&cg_obj, ib_dev, RDMACG_RESOURCE_HCA_HANDLE); if (ret) @@ -358,7 +358,7 @@ ssize_t ib_uverbs_alloc_pd(struct ib_uverbs_file *file, ib_uverbs_init_udata(&udata, buf + sizeof(cmd), u64_to_user_ptr(cmd.response) + sizeof(resp), in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr), - out_len - sizeof(resp)); + out_len - sizeof(resp), file->ucontext); uobj = uobj_alloc(UVERBS_OBJECT_PD, file, &ib_dev); if (IS_ERR(uobj)) @@ -519,7 +519,7 @@ ssize_t ib_uverbs_open_xrcd(struct ib_uverbs_file *file, ib_uverbs_init_udata(&udata, buf + sizeof(cmd), u64_to_user_ptr(cmd.response) + sizeof(resp), in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr), - out_len - sizeof(resp)); + out_len - sizeof(resp), file->ucontext); mutex_lock(&file->device->xrcd_tree_mutex); @@ -676,7 +676,7 @@ ssize_t ib_uverbs_reg_mr(struct ib_uverbs_file *file, ib_uverbs_init_udata(&udata, buf + sizeof(cmd), u64_to_user_ptr(cmd.response) + sizeof(resp), in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr), - out_len - sizeof(resp)); + out_len - sizeof(resp), file->ucontext); if ((cmd.start & ~PAGE_MASK) != (cmd.hca_va & ~PAGE_MASK)) return -EINVAL; @@ -769,7 +769,7 @@ ssize_t ib_uverbs_rereg_mr(struct ib_uverbs_file *file, ib_uverbs_init_udata(&udata, buf + sizeof(cmd), u64_to_user_ptr(cmd.response) + sizeof(resp), in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr), - out_len - sizeof(resp)); + out_len - sizeof(resp), file->ucontext); if (cmd.flags & ~IB_MR_REREG_SUPPORTED || !cmd.flags) return -EINVAL; @@ -883,7 +883,7 @@ ssize_t ib_uverbs_alloc_mw(struct ib_uverbs_file *file, ib_uverbs_init_udata(&udata, buf + sizeof(cmd), u64_to_user_ptr(cmd.response) + sizeof(resp), in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr), - out_len - sizeof(resp)); + out_len - sizeof(resp), file->ucontext); mw = pd->device->alloc_mw(pd, cmd.mw_type, &udata); if (IS_ERR(mw)) { @@ -1095,12 +1095,12 @@ ssize_t ib_uverbs_create_cq(struct ib_uverbs_file *file, return -EFAULT; ib_uverbs_init_udata(&ucore, buf, u64_to_user_ptr(cmd.response), - sizeof(cmd), sizeof(resp)); + sizeof(cmd), sizeof(resp), file->ucontext); ib_uverbs_init_udata(&uhw, buf + sizeof(cmd), u64_to_user_ptr(cmd.response) + sizeof(resp), in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr), - out_len - sizeof(resp)); + out_len - sizeof(resp), file->ucontext); memset(&cmd_ex, 0, sizeof(cmd_ex)); cmd_ex.user_handle = cmd.user_handle; @@ -1179,7 +1179,7 @@ ssize_t ib_uverbs_resize_cq(struct ib_uverbs_file *file, ib_uverbs_init_udata(&udata, buf + sizeof(cmd), u64_to_user_ptr(cmd.response) + sizeof(resp), in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr), - out_len - sizeof(resp)); + out_len - sizeof(resp), file->ucontext); cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, file); if (!cq) @@ -1636,11 +1636,11 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file, return -EFAULT; ib_uverbs_init_udata(&ucore, buf, u64_to_user_ptr(cmd.response), - sizeof(cmd), resp_size); + sizeof(cmd), resp_size, file->ucontext); ib_uverbs_init_udata(&uhw, buf + sizeof(cmd), u64_to_user_ptr(cmd.response) + resp_size, in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr), - out_len - resp_size); + out_len - resp_size, file->ucontext); memset(&cmd_ex, 0, sizeof(cmd_ex)); cmd_ex.user_handle = cmd.user_handle; @@ -1737,7 +1737,7 @@ ssize_t ib_uverbs_open_qp(struct ib_uverbs_file *file, ib_uverbs_init_udata(&udata, buf + sizeof(cmd), u64_to_user_ptr(cmd.response) + sizeof(resp), in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr), - out_len - sizeof(resp)); + out_len - sizeof(resp), file->ucontext); obj = (struct ib_uqp_object *)uobj_alloc(UVERBS_OBJECT_QP, file, &ib_dev); @@ -2089,7 +2089,7 @@ ssize_t ib_uverbs_modify_qp(struct ib_uverbs_file *file, ib_uverbs_init_udata(&udata, buf + sizeof(cmd.base), NULL, in_len - sizeof(cmd.base) - sizeof(struct ib_uverbs_cmd_hdr), - out_len); + out_len, file->ucontext); ret = modify_qp(file, &cmd, &udata); if (ret) @@ -2573,7 +2573,7 @@ ssize_t ib_uverbs_create_ah(struct ib_uverbs_file *file, ib_uverbs_init_udata(&udata, buf + sizeof(cmd), u64_to_user_ptr(cmd.response) + sizeof(resp), in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr), - out_len - sizeof(resp)); + out_len - sizeof(resp), file->ucontext); uobj = uobj_alloc(UVERBS_OBJECT_AH, file, &ib_dev); if (IS_ERR(uobj)) @@ -3808,7 +3808,7 @@ ssize_t ib_uverbs_create_srq(struct ib_uverbs_file *file, ib_uverbs_init_udata(&udata, buf + sizeof(cmd), u64_to_user_ptr(cmd.response) + sizeof(resp), in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr), - out_len - sizeof(resp)); + out_len - sizeof(resp), file->ucontext); ret = __uverbs_create_xsrq(file, &xcmd, &udata); if (ret) @@ -3834,7 +3834,7 @@ ssize_t ib_uverbs_create_xsrq(struct ib_uverbs_file *file, ib_uverbs_init_udata(&udata, buf + sizeof(cmd), u64_to_user_ptr(cmd.response) + sizeof(resp), in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr), - out_len - sizeof(resp)); + out_len - sizeof(resp), file->ucontext); ret = __uverbs_create_xsrq(file, &cmd, &udata); if (ret) @@ -3857,7 +3857,7 @@ ssize_t ib_uverbs_modify_srq(struct ib_uverbs_file *file, return -EFAULT; ib_uverbs_init_udata(&udata, buf + sizeof cmd, NULL, in_len - sizeof cmd, - out_len); + out_len, file->ucontext); srq = uobj_get_obj_read(srq, UVERBS_OBJECT_SRQ, cmd.srq_handle, file); if (!srq) diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c index 12d8f8097574..50432f4eb36a 100644 --- a/drivers/infiniband/core/uverbs_main.c +++ b/drivers/infiniband/core/uverbs_main.c @@ -775,13 +775,15 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf, ib_uverbs_init_udata_buf_or_null(&ucore, buf, u64_to_user_ptr(ex_hdr.response), - hdr.in_words * 8, hdr.out_words * 8); + hdr.in_words * 8, hdr.out_words * 8, + file->ucontext); ib_uverbs_init_udata_buf_or_null(&uhw, buf + ucore.inlen, u64_to_user_ptr(ex_hdr.response) + ucore.outlen, ex_hdr.provider_in_words * 8, - ex_hdr.provider_out_words * 8); + ex_hdr.provider_out_words * 8, + file->ucontext); ret = uverbs_ex_cmd_table[command](file, &ucore, &uhw); ret = (ret) ? : count;