From patchwork Tue Dec 29 15:07:35 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Khapyorsky X-Patchwork-Id: 70108 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.2) with ESMTP id nBTF4aL3029049 for ; Tue, 29 Dec 2009 15:04:36 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752272AbZL2PEf (ORCPT ); Tue, 29 Dec 2009 10:04:35 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752235AbZL2PEf (ORCPT ); Tue, 29 Dec 2009 10:04:35 -0500 Received: from mail-ew0-f219.google.com ([209.85.219.219]:64937 "EHLO mail-ew0-f219.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751925AbZL2PEf (ORCPT ); Tue, 29 Dec 2009 10:04:35 -0500 Received: by ewy19 with SMTP id 19so2779180ewy.21 for ; Tue, 29 Dec 2009 07:04:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:received:date:from:to :cc:subject:message-id:references:mime-version:content-type :content-disposition:in-reply-to:user-agent; bh=xQqe+Td28E5B84fFcKYkz508Np5TNwhYa1slXAdX1sA=; b=AsqH69VBqR3c+l7Ox2M0YsHKiSAgE6KplIjX0kmjLz2sy11IB9O0nO3MpYlrlbMdBE rRlbv2lMTFHRL5HbxvKRHgYMCmPgtPtH990SD8gukue9XEEpG869RV6Cz83yvQBOAdys v137ZW0Xv2WjOlQJ2Ph73hrz3sjYcutYIoNGQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=npu44bCqnI7CbCqMbMm4waS/L3KYsyPruA/68ClqyqWepK5tymILqRPREgTNz2PuJ3 dTHqoewlyZPHDTl+smAl9jkkFJCuaMBN19D44AjQaph2mFhhm71t2pPqcvXRjYJpuVe8 LSJ6ZCE7vcetQSUMVSUwRGaMOTRV3/X/zxNfA= Received: by 10.213.100.229 with SMTP id z37mr20447590ebn.87.1262099073432; Tue, 29 Dec 2009 07:04:33 -0800 (PST) Received: from me.localdomain (85.64.35.106.dynamic.barak-online.net [85.64.35.106]) by mx.google.com with ESMTPS id 24sm26197932eyx.46.2009.12.29.07.04.32 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 29 Dec 2009 07:04:32 -0800 (PST) Received: by me.localdomain (Postfix, from userid 1000) id 1DB6911DF8; Tue, 29 Dec 2009 17:07:35 +0200 (IST) Date: Tue, 29 Dec 2009 17:07:35 +0200 From: Sasha Khapyorsky To: linux-rdma@vger.kernel.org Cc: Hal Rosenstock Subject: [PATCH] opensm/osm_slvl_map_rcv.c: verify port number values received from network Message-ID: <20091229150735.GX26940@me> References: <20091201194110.GA26753@comcast.net> <20091229150528.GV26940@me> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20091229150528.GV26940@me> User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org diff --git a/opensm/opensm/osm_slvl_map_rcv.c b/opensm/opensm/osm_slvl_map_rcv.c index b35d867..6229db9 100644 --- a/opensm/opensm/osm_slvl_map_rcv.c +++ b/opensm/opensm/osm_slvl_map_rcv.c @@ -104,8 +104,17 @@ void osm_slvl_rcv_process(IN void *context, IN void *p_data) /* in case of a non switch node the attr modifier should be ignored */ if (osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH) { + unsigned num_ports = osm_node_get_num_physp(p_node) - 1; out_port_num = cl_ntoh32(p_smp->attr_mod) & 0xff; in_port_num = (cl_ntoh32(p_smp->attr_mod) >> 8) & 0xff; + if (in_port_num > num_ports || out_port_num > num_ports) { + OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2C07" + "Invalid attribute modifier 0x%x reveived in" + " response from switch 0x%" PRIx64 "\n", + cl_ntoh32(p_smp->attr_mod), + cl_ntoh64(node_guid)); + goto Exit; + } p_physp = osm_node_get_physp_ptr(p_node, out_port_num); } else { p_physp = p_port->p_physp;