From patchwork Tue May 24 14:35:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 9133773 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 8DE4A607D3 for ; Tue, 24 May 2016 14:35:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 818B428117 for ; Tue, 24 May 2016 14:35:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 76A592827A; Tue, 24 May 2016 14:35:58 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 1108928117 for ; Tue, 24 May 2016 14:35:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754745AbcEXOf5 (ORCPT ); Tue, 24 May 2016 10:35:57 -0400 Received: from mail.kernel.org ([198.145.29.136]:43052 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752991AbcEXOf4 (ORCPT ); Tue, 24 May 2016 10:35:56 -0400 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7304220351; Tue, 24 May 2016 14:35:55 +0000 (UTC) Received: from localhost (unknown [213.57.247.249]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1EBA020251; Tue, 24 May 2016 14:35:53 +0000 (UTC) From: Leon Romanovsky To: dledford@redhat.com Cc: linux-rdma@vger.kernel.org, Matan Barak , Leon Romanovsky , Haggai Eran Subject: [RFC ABI 6/8] IB/core: Add outptr to udata in order to track the output size Date: Tue, 24 May 2016 17:35:24 +0300 Message-Id: <1464100526-31730-7-git-send-email-leonro@mellanox.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1464100526-31730-1-git-send-email-leonro@mellanox.com> References: <1464100526-31730-1-git-send-email-leonro@mellanox.com> X-Virus-Scanned: ClamAV using ClamSMTP 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 From: Matan Barak Sometimes, a netlink attribute describes a response buffer. For example, when a vendor writes a response, the uptr netlink attribute in the core response describe the vendor's response length. Similarly, the core response length is described by its header, which is actually a netsted netlink attribute. Therefore, we need to have a way to count how much data was written to the udata. Adding an outptr to track this data. Signed-off-by: Leon Romanovsky Signed-off-by: Matan Barak Signed-off-by: Haggai Eran --- drivers/infiniband/core/uverbs.h | 3 +++ include/rdma/ib_verbs.h | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h index a46cb29..c8d8700 100644 --- a/drivers/infiniband/core/uverbs.h +++ b/drivers/infiniband/core/uverbs.h @@ -46,11 +46,13 @@ #include #include #include +#include #define INIT_UDATA(udata, ibuf, obuf, ilen, olen) \ do { \ (udata)->inbuf = (const void __user *) (ibuf); \ (udata)->outbuf = (void __user *) (obuf); \ + (udata)->outptr = (void __user *)(obuf); \ (udata)->inlen = (ilen); \ (udata)->outlen = (olen); \ } while (0) @@ -59,6 +61,7 @@ do { \ (udata)->inbuf = (ilen) ? (const void __user *) (ibuf) : NULL; \ (udata)->outbuf = (olen) ? (void __user *) (obuf) : NULL; \ + (udata)->outptr = (olen) ? (void __user *)(obuf) : NULL; \ (udata)->inlen = (ilen); \ (udata)->outlen = (olen); \ } while (0) diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 1904c02..f5275b9 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -1360,6 +1360,7 @@ struct ib_uobject { struct ib_udata { const void __user *inbuf; void __user *outbuf; + void __user *outptr; size_t inlen; size_t outlen; }; @@ -1990,7 +1991,12 @@ static inline int ib_copy_from_udata(void *dest, struct ib_udata *udata, size_t static inline int ib_copy_to_udata(struct ib_udata *udata, void *src, size_t len) { - return copy_to_user(udata->outbuf, src, len) ? -EFAULT : 0; + int ret = copy_to_user(udata->outptr, src, len) ? -EFAULT : 0; + + if (!ret) + udata->outptr += len; + + return ret; } static inline bool ib_is_udata_cleared(struct ib_udata *udata,