From patchwork Sun Aug 18 18:28:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yann Droneaud X-Patchwork-Id: 2846217 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 45AFBBF546 for ; Sun, 18 Aug 2013 18:35:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 58D3520214 for ; Sun, 18 Aug 2013 18:35:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4BE0920201 for ; Sun, 18 Aug 2013 18:35:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754522Ab3HRSfm (ORCPT ); Sun, 18 Aug 2013 14:35:42 -0400 Received: from smtp1-g21.free.fr ([212.27.42.1]:57434 "EHLO smtp1-g21.free.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754427Ab3HRSfm (ORCPT ); Sun, 18 Aug 2013 14:35:42 -0400 Received: from localhost.localdomain (unknown [IPv6:2a01:e35:2e9f:6ac0:f909:bc73:7b7d:1daf]) by smtp1-g21.free.fr (Postfix) with ESMTP id C6EBB940189; Sun, 18 Aug 2013 20:35:33 +0200 (CEST) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by localhost.localdomain (8.14.7/8.14.7) with ESMTP id r7IITSIi031985; Sun, 18 Aug 2013 20:29:28 +0200 Received: (from ydroneaud@localhost) by localhost.localdomain (8.14.7/8.14.7/Submit) id r7IITSUA031984; Sun, 18 Aug 2013 20:29:28 +0200 From: Yann Droneaud To: linux-rdma@vger.kernel.org Cc: Yann Droneaud Subject: [PATCH 06/22] ucm: changes ib_ucm_alloc_data() src arg to be a pointer Date: Sun, 18 Aug 2013 20:28:42 +0200 Message-Id: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP ib_icm_alloc_data() is a function to allocate a buffer to copy a userspace provided buffer. This patch makes 'src' argument to be an explicit pointer to userspace buffer, so that static analysis won't get fooled by 'src' being currently an integer without annotation. Signed-off-by: Yann Droneaud Link: http://mid.gmane.org/cover.1376847403.git.ydroneaud@opteya.com --- drivers/infiniband/core/ucm.c | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c index e462208..d336a1b 100644 --- a/drivers/infiniband/core/ucm.c +++ b/drivers/infiniband/core/ucm.c @@ -685,7 +685,7 @@ static ssize_t ib_ucm_notify(struct ib_ucm_file *file, return result; } -static int ib_ucm_alloc_data(const void **dest, u64 src, u32 len) +static int ib_ucm_alloc_data(const void **dest, const void __user *src, u32 len) { void *data; @@ -694,7 +694,7 @@ static int ib_ucm_alloc_data(const void **dest, u64 src, u32 len) if (!len) return 0; - data = memdup_user((void __user *)(unsigned long)src, len); + data = memdup_user(src, len); if (IS_ERR(data)) return PTR_ERR(data); @@ -744,7 +744,9 @@ static ssize_t ib_ucm_send_req(struct ib_ucm_file *file, if (copy_from_user(&cmd, inbuf, sizeof(cmd))) return -EFAULT; - result = ib_ucm_alloc_data(¶m.private_data, cmd.data, cmd.len); + result = ib_ucm_alloc_data(¶m.private_data, + (const void __user *)(unsigned long)cmd.data, + cmd.len); if (result) goto done; @@ -800,7 +802,9 @@ static ssize_t ib_ucm_send_rep(struct ib_ucm_file *file, if (copy_from_user(&cmd, inbuf, sizeof(cmd))) return -EFAULT; - result = ib_ucm_alloc_data(¶m.private_data, cmd.data, cmd.len); + result = ib_ucm_alloc_data(¶m.private_data, + (const void __user *)(unsigned long)cmd.data, + cmd.len); if (result) return result; @@ -840,7 +844,9 @@ static ssize_t ib_ucm_send_private_data(struct ib_ucm_file *file, if (copy_from_user(&cmd, inbuf, sizeof(cmd))) return -EFAULT; - result = ib_ucm_alloc_data(&private_data, cmd.data, cmd.len); + result = ib_ucm_alloc_data(&private_data, + (const void __user *)(unsigned long)cmd.data, + cmd.len); if (result) return result; @@ -894,11 +900,15 @@ static ssize_t ib_ucm_send_info(struct ib_ucm_file *file, if (copy_from_user(&cmd, inbuf, sizeof(cmd))) return -EFAULT; - result = ib_ucm_alloc_data(&data, cmd.data, cmd.data_len); + result = ib_ucm_alloc_data(&data, + (const void __user *)(unsigned long)cmd.data, + cmd.data_len); if (result) goto done; - result = ib_ucm_alloc_data(&info, cmd.info, cmd.info_len); + result = ib_ucm_alloc_data(&info, + (const void __user *)(unsigned long)cmd.info, + cmd.info_len); if (result) goto done; @@ -942,7 +952,9 @@ static ssize_t ib_ucm_send_mra(struct ib_ucm_file *file, if (copy_from_user(&cmd, inbuf, sizeof(cmd))) return -EFAULT; - result = ib_ucm_alloc_data(&data, cmd.data, cmd.len); + result = ib_ucm_alloc_data(&data, + (const void __user *)(unsigned long)cmd.data, + cmd.len); if (result) return result; @@ -970,7 +982,9 @@ static ssize_t ib_ucm_send_lap(struct ib_ucm_file *file, if (copy_from_user(&cmd, inbuf, sizeof(cmd))) return -EFAULT; - result = ib_ucm_alloc_data(&data, cmd.data, cmd.len); + result = ib_ucm_alloc_data(&data, + (const void __user *)(unsigned long)cmd.data, + cmd.len); if (result) goto done; @@ -1006,7 +1020,9 @@ static ssize_t ib_ucm_send_sidr_req(struct ib_ucm_file *file, if (copy_from_user(&cmd, inbuf, sizeof(cmd))) return -EFAULT; - result = ib_ucm_alloc_data(¶m.private_data, cmd.data, cmd.len); + result = ib_ucm_alloc_data(¶m.private_data, + (const void __user *)(unsigned long)cmd.data, + cmd.len); if (result) goto done; @@ -1047,11 +1063,14 @@ static ssize_t ib_ucm_send_sidr_rep(struct ib_ucm_file *file, return -EFAULT; result = ib_ucm_alloc_data(¶m.private_data, - cmd.data, cmd.data_len); + (void __user *)(unsigned long)cmd.data, + cmd.data_len); if (result) goto done; - result = ib_ucm_alloc_data(¶m.info, cmd.info, cmd.info_len); + result = ib_ucm_alloc_data(¶m.info, + (void __user *)(unsigned long)cmd.info, + cmd.info_len); if (result) goto done;