From patchwork Sun Aug 18 18:28:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yann Droneaud X-Patchwork-Id: 2846215 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A39729F271 for ; Sun, 18 Aug 2013 18:35:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EE52320212 for ; Sun, 18 Aug 2013 18:35:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 157E220201 for ; Sun, 18 Aug 2013 18:35:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754520Ab3HRSfa (ORCPT ); Sun, 18 Aug 2013 14:35:30 -0400 Received: from smtp1-g21.free.fr ([212.27.42.1]:56923 "EHLO smtp1-g21.free.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754427Ab3HRSfa (ORCPT ); Sun, 18 Aug 2013 14:35:30 -0400 Received: from localhost.localdomain (unknown [IPv6:2a01:e35:2e9f:6ac0:f909:bc73:7b7d:1daf]) by smtp1-g21.free.fr (Postfix) with ESMTP id A1991940165; Sun, 18 Aug 2013 20:35:21 +0200 (CEST) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by localhost.localdomain (8.14.7/8.14.7) with ESMTP id r7IITUvV032037; Sun, 18 Aug 2013 20:29:30 +0200 Received: (from ydroneaud@localhost) by localhost.localdomain (8.14.7/8.14.7/Submit) id r7IITUWb032036; Sun, 18 Aug 2013 20:29:30 +0200 From: Yann Droneaud To: linux-rdma@vger.kernel.org Cc: Yann Droneaud Subject: [PATCH 19/22] uverbs: check output length Date: Sun, 18 Aug 2013 20:28:55 +0200 Message-Id: <8fd74e036ebaab25266672aa8097af44c4cb35c3.1376847403.git.ydroneaud@opteya.com> 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=unavailable 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 Makes uverbs functions check the length of the output buffer: this will prevent uverbs from writing past userspace provided buffer. Signed-off-by: Yann Droneaud Link: http://mid.gmane.org/cover.1376847403.git.ydroneaud@opteya.com --- drivers/infiniband/core/uverbs_cmd.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index d0f9854..dc0574f 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -1359,6 +1359,9 @@ ssize_t ib_uverbs_resize_cq(struct ib_uverbs_file *file, if (in_len < sizeof cmd) return -EINVAL; + if (out_len < sizeof resp) + return -ENOSPC; + if (copy_from_user(&cmd, buf, sizeof cmd)) return -EFAULT; @@ -1427,6 +1430,9 @@ ssize_t ib_uverbs_poll_cq(struct ib_uverbs_file *file, if (in_len < sizeof cmd) return -EINVAL; + if (out_len < sizeof resp) + return -ENOSPC; + if (copy_from_user(&cmd, buf, sizeof cmd)) return -EFAULT; @@ -1506,6 +1512,9 @@ ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file, if (in_len < sizeof cmd) return -EINVAL; + if (out_len < sizeof resp) + return -ENOSPC; + if (copy_from_user(&cmd, buf, sizeof cmd)) return -EFAULT; @@ -1855,6 +1864,9 @@ ssize_t ib_uverbs_query_qp(struct ib_uverbs_file *file, if (in_len < sizeof cmd) return -EINVAL; + if (out_len < sizeof resp) + return -ENOSPC; + if (copy_from_user(&cmd, buf, sizeof cmd)) return -EFAULT; @@ -2067,6 +2079,9 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file, if (in_len < sizeof cmd) return -EINVAL; + if (out_len < sizeof resp) + return -ENOSPC; + if (copy_from_user(&cmd, buf, sizeof cmd)) return -EFAULT; @@ -2130,6 +2145,9 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file, if (in_len < sizeof cmd) return -EINVAL; + if (out_len < sizeof resp) + return -ENOSPC; + if (copy_from_user(&cmd, buf, sizeof cmd)) return -EFAULT; @@ -2371,6 +2389,9 @@ ssize_t ib_uverbs_post_recv(struct ib_uverbs_file *file, if (in_len < sizeof cmd) return -EINVAL; + if (out_len < sizeof resp) + return -ENOSPC; + if (copy_from_user(&cmd, buf, sizeof cmd)) return -EFAULT; @@ -2423,6 +2444,9 @@ ssize_t ib_uverbs_post_srq_recv(struct ib_uverbs_file *file, if (in_len < sizeof cmd) return -EINVAL; + if (out_len < sizeof resp) + return -ENOSPC; + if (copy_from_user(&cmd, buf, sizeof cmd)) return -EFAULT; @@ -2975,6 +2999,9 @@ ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file, if (in_len < sizeof cmd) return -EINVAL; + if (out_len < sizeof resp) + return -ENOSPC; + if (copy_from_user(&cmd, buf, sizeof cmd)) return -EFAULT;