From patchwork Sun Aug 18 18:28:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yann Droneaud X-Patchwork-Id: 2846209 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 41C83BF546 for ; Sun, 18 Aug 2013 18:34:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6DD3020212 for ; Sun, 18 Aug 2013 18:34:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8E8A720201 for ; Sun, 18 Aug 2013 18:34:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754360Ab3HRSet (ORCPT ); Sun, 18 Aug 2013 14:34:49 -0400 Received: from smtp1-g21.free.fr ([212.27.42.1]:54657 "EHLO smtp1-g21.free.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753704Ab3HRSes (ORCPT ); Sun, 18 Aug 2013 14:34:48 -0400 Received: from localhost.localdomain (unknown [IPv6:2a01:e35:2e9f:6ac0:f909:bc73:7b7d:1daf]) by smtp1-g21.free.fr (Postfix) with ESMTP id 0F972940155; Sun, 18 Aug 2013 20:34:39 +0200 (CEST) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by localhost.localdomain (8.14.7/8.14.7) with ESMTP id r7IITTxw032017; Sun, 18 Aug 2013 20:29:29 +0200 Received: (from ydroneaud@localhost) by localhost.localdomain (8.14.7/8.14.7/Submit) id r7IITThw032016; Sun, 18 Aug 2013 20:29:29 +0200 From: Yann Droneaud To: linux-rdma@vger.kernel.org Cc: Yann Droneaud Subject: [PATCH 14/22] ucma: ucma_query_path(): check output length Date: Sun, 18 Aug 2013 20:28:50 +0200 Message-Id: <74830c785f6cb033b5e9ac89df56e9144d4d08d3.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 ucma_query_path() check the length of the output buffer: this will prevent the function 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/ucma.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c index a155169..c653b1e 100644 --- a/drivers/infiniband/core/ucma.c +++ b/drivers/infiniband/core/ucma.c @@ -838,6 +838,9 @@ static ssize_t ucma_query_path(struct ucma_context *ctx, if (out_len < sizeof(*resp)) return -ENOSPC; + if ((out_len - sizeof(*resp))/sizeof(struct ib_path_rec_data) < ctx->cm_id->route.num_paths) + return -ENOSPC; + resp = kzalloc(out_len, GFP_KERNEL); if (!resp) return -ENOMEM;