From patchwork Tue Sep 11 15:32:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yevgeny Kliteynik X-Patchwork-Id: 1438681 X-Patchwork-Delegate: alexne@voltaire.com Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 836F7DFAF3 for ; Tue, 11 Sep 2012 15:32:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756750Ab2IKPcS (ORCPT ); Tue, 11 Sep 2012 11:32:18 -0400 Received: from eu1sys200aog119.obsmtp.com ([207.126.144.147]:51847 "HELO eu1sys200aog119.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751642Ab2IKPcS (ORCPT ); Tue, 11 Sep 2012 11:32:18 -0400 Received: from MTLCAS01.mtl.com ([193.47.165.155]) (using TLSv1) by eu1sys200aob119.postini.com ([207.126.147.11]) with SMTP ID DSNKUE9ZfQzyUEBuQCuFbdR7URt7UhEnD8t/@postini.com; Tue, 11 Sep 2012 15:32:17 UTC Received: from [10.7.17.62] (10.0.13.1) by MTLCAS01.mtl.com (10.0.8.71) with Microsoft SMTP Server id 14.2.247.3; Tue, 11 Sep 2012 18:32:11 +0300 Message-ID: <504F597B.1060507@mellanox.co.il> Date: Tue, 11 Sep 2012 18:32:11 +0300 From: Yevgeny Kliteynik Reply-To: User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120713 Thunderbird/14.0 MIME-Version: 1.0 To: , Linux RDMA , Yevgeny Kliteynik Subject: [PATCH 7/8 v2] opensm/osm_port_info_rcv.c: check received local_port_num X-Originating-IP: [10.0.13.1] Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Signed-off-by: Yevgeny Kliteynik --- opensm/osm_port_info_rcv.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/opensm/osm_port_info_rcv.c b/opensm/osm_port_info_rcv.c index c3bc66c..442bc3f 100644 --- a/opensm/osm_port_info_rcv.c +++ b/opensm/osm_port_info_rcv.c @@ -505,6 +505,11 @@ void osm_pi_rcv_process(IN void *context, IN void *data) CL_ASSERT(p_smp->attr_id == IB_MAD_ATTR_PORT_INFO); + /* + * Attribute modifier has already been validated upon MAD receive, + * which means that port_num has to be valid - it originated from + * the request attribute modifier. + */ port_num = (uint8_t) cl_ntoh32(p_smp->attr_mod); port_guid = p_context->port_guid; @@ -554,6 +559,17 @@ void osm_pi_rcv_process(IN void *context, IN void *data) p_node = p_port->p_node; CL_ASSERT(p_node); + if (p_pi->local_port_num > p_node->node_info.num_ports) { + CL_PLOCK_RELEASE(sm->p_lock); + OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0F15: " + "Received PortInfo for port GUID 0x%" PRIx64 " is " + "non-compliant and is being ignored since the " + "local port num %u > num ports %u\n", + cl_ntoh64(port_guid), p_pi->local_port_num, + p_node->node_info.num_ports); + goto Exit; + } + /* If we were setting the PortInfo, then receiving this attribute was not part of sweeping the subnet.