From patchwork Thu Oct 23 14:00:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 5140831 X-Patchwork-Delegate: hal@mellanox.com 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 451F2C11AC for ; Thu, 23 Oct 2014 14:00:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 47CF320251 for ; Thu, 23 Oct 2014 14:00:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 51E8E2024F for ; Thu, 23 Oct 2014 14:00:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754766AbaJWOAW (ORCPT ); Thu, 23 Oct 2014 10:00:22 -0400 Received: from mail-wi0-f176.google.com ([209.85.212.176]:56107 "EHLO mail-wi0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752970AbaJWOAV (ORCPT ); Thu, 23 Oct 2014 10:00:21 -0400 Received: by mail-wi0-f176.google.com with SMTP id n3so3734127wiv.15 for ; Thu, 23 Oct 2014 07:00:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:content-type:content-transfer-encoding; bh=UCQD/CahVQJ01n84Z+ZHfLwxURlT78XlSqiGuwWP64E=; b=IlllZBmNuvG5AjClU2cyklM2l7o9x0Z/6Ogi/o/LNVP3OLDrhki/fknQUvtxoq8gc+ 1rNgmvxdI0Rvmj2RIryXMpuyVNs4eH9/vH3u7HJZgJjaAErFI46hwpxMl4lJN5bSmBFW euoI6/Hh2R04WYikgzQ+4fW3INQjhNCQq2JjWMs29S/RU6RsDOEBGnBu1LWNVsLktwhG o22eKciZmlJqzxWWYoqffDYlp/NbHVC4b0ERx8sD5DymBAErhsxPW9x422o/NvQdScgC w08LAY7OItElcMzwf3jBesYGEJEMj+WRtk5/PnjoIPPM+fpnZmjRpzJqnbKU3+NGgboy 4fmQ== X-Gm-Message-State: ALoCoQkgAh1pnR7bMlId0Nr8dCpAvTfR/Jf9lysCYN0dJI1iD2WBfSrR6IHdwe2/Prf9QXABjjwe X-Received: by 10.194.77.4 with SMTP id o4mr5719872wjw.41.1414072820233; Thu, 23 Oct 2014 07:00:20 -0700 (PDT) Received: from [192.168.1.102] (c-98-229-118-119.hsd1.ma.comcast.net. [98.229.118.119]) by mx.google.com with ESMTPSA id l17sm2707734wiw.7.2014.10.23.07.00.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 Oct 2014 07:00:19 -0700 (PDT) Message-ID: <544909EE.9030505@dev.mellanox.co.il> Date: Thu, 23 Oct 2014 10:00:14 -0400 From: Hal Rosenstock User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 MIME-Version: 1.0 To: "linux-rdma (linux-rdma@vger.kernel.org)" CC: Daniel Klein , Vladimir Koushnir Subject: [PATCH opensm] complib/cl_dispatcher.c: Check registrations vector size when searching for handlers Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-8.3 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 From: Daniel Klein When cl_disp_post is called with message_id != CL_DISP_MSGID_NONE, it searches for the handler for the message in a vector using message_id as the index. This change adds a check to verify that the message_id that is used as an index is not larger than vector's size. This change adds resiliency to the code when cl_disp_post() is called with an invalid message_id. Signed-off-by: Daniel Klein Signed-off-by: Hal Rosenstock --- complib/cl_dispatcher.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/complib/cl_dispatcher.c b/complib/cl_dispatcher.c index 6736d67..1255c83 100644 --- a/complib/cl_dispatcher.c +++ b/complib/cl_dispatcher.c @@ -302,6 +302,11 @@ cl_status_t cl_disp_post(IN const cl_disp_reg_handle_t handle, cl_spinlock_acquire(&p_disp->lock); /* Check that the recipient exists. */ + if (cl_ptr_vector_get_size(&p_disp->reg_vec) <= msg_id) { + cl_spinlock_release(&p_disp->lock); + return (CL_NOT_FOUND); + } + p_dest_reg = cl_ptr_vector_get(&p_disp->reg_vec, msg_id); if (!p_dest_reg) { cl_spinlock_release(&p_disp->lock);