From patchwork Thu Dec 26 13:39:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 3406791 X-Patchwork-Delegate: hal@mellanox.com 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 D9B109F380 for ; Thu, 26 Dec 2013 13:39:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0FEAB2012E for ; Thu, 26 Dec 2013 13:39:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3FF1120136 for ; Thu, 26 Dec 2013 13:39:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752977Ab3LZNjY (ORCPT ); Thu, 26 Dec 2013 08:39:24 -0500 Received: from mail-ee0-f52.google.com ([74.125.83.52]:53695 "EHLO mail-ee0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752970Ab3LZNjR (ORCPT ); Thu, 26 Dec 2013 08:39:17 -0500 Received: by mail-ee0-f52.google.com with SMTP id d17so3641361eek.25 for ; Thu, 26 Dec 2013 05:39:16 -0800 (PST) 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=0JFjuy9mG2ticDPapJP/ZExBn3POI2CtEzsD4rNoVGo=; b=fc85H6lOTW0i6GejYSIqccfKiHJ5jNvnmpawckuDA8uhDKuj1Epp4FkBDF23mwoW7k bJwMoXEz1lNV7EKvI6ZEf4II9qkrpA0A423i9opeE8fQVpySE4c6jZl5UaPxT/0t8h60 fFyPebDJBFp8afCkHqMVbIOhoUZxwRD7sQLRjjGqilmgIeJZOOY/zRMNq5c1/47knYPW vAnNmu2k47/ymLG5e/hoxzLnquVM4tRkhuiPMpEMv494F9k96y+7qbuFN0sKUkK2L+WN hIuSFueh009uA2i6niR2WErpV1kMAGY1uwqviFp8RCb2NLNnCvrd8I4cyt3xM7hV+CTM aMYA== X-Gm-Message-State: ALoCoQnhQMGi29nrkll/6BKjgQKXfl4NYaeWhlemyJZjCxGbJys7/vCPZfu8umZQ65Icz8Yu7ojz X-Received: by 10.15.36.135 with SMTP id i7mr7412418eev.93.1388065156008; Thu, 26 Dec 2013 05:39:16 -0800 (PST) Received: from [192.168.0.15] ([97.104.4.183]) by mx.google.com with ESMTPSA id z42sm72894389eeo.17.2013.12.26.05.39.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 26 Dec 2013 05:39:15 -0800 (PST) Message-ID: <52BC3180.1090203@dev.mellanox.co.il> Date: Thu, 26 Dec 2013 08:39:12 -0500 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: Vladimir Koushnir Subject: [PATCH opensm] osm_ucast_file.c: Fix crash when port is invalid in LFT file Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.5 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: Vladimir Koushnir Signed-off-by: Vladimir Koushnir Signed-off-by: Hal Rosenstock --- opensm/osm_ucast_file.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/opensm/osm_ucast_file.c b/opensm/osm_ucast_file.c index 2c2bf0c..a5408af 100644 --- a/opensm/osm_ucast_file.c +++ b/opensm/osm_ucast_file.c @@ -216,6 +216,17 @@ static int do_ucast_file_load(void *context) file_name, lineno, p); goto Exit; } + if (port_num >= + osm_node_get_num_physp(p_sw->p_node)) { + OSM_LOG(&p_osm->log, OSM_LOG_ERROR, + "Invalid port %d found " + "for switch %016" PRIx64 "\n", + port_num, + cl_ntoh64(osm_node_get_node_guid + (p_sw->p_node))); + goto Exit; + } + p = q; /* additionally try to extract guid */ q = strstr(p, " portguid 0x");