From patchwork Thu Oct 22 18:04:25 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 55403 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n9MI7Cxi000572 for ; Thu, 22 Oct 2009 18:07:32 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755594AbZJVSH1 (ORCPT ); Thu, 22 Oct 2009 14:07:27 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755888AbZJVSH0 (ORCPT ); Thu, 22 Oct 2009 14:07:26 -0400 Received: from qmta14.westchester.pa.mail.comcast.net ([76.96.59.212]:54376 "EHLO QMTA14.westchester.pa.mail.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755594AbZJVSH0 (ORCPT ); Thu, 22 Oct 2009 14:07:26 -0400 Received: from OMTA17.westchester.pa.mail.comcast.net ([76.96.62.89]) by QMTA14.westchester.pa.mail.comcast.net with comcast id vu7M1c06E1vXlb85Eu7MBd; Thu, 22 Oct 2009 18:07:30 +0000 Received: from hal.comcast.net ([75.69.247.31]) by OMTA17.westchester.pa.mail.comcast.net with comcast id vuDs1c0040hNrtn3duDs0k; Thu, 22 Oct 2009 18:13:52 +0000 Received: from hal.comcast.net (localhost.localdomain [127.0.0.1]) by hal.comcast.net (8.14.3/8.14.3) with ESMTP id n9MI4eS3013326; Thu, 22 Oct 2009 14:04:45 -0400 Received: (from hnrose@localhost) by hal.comcast.net (8.14.3/8.14.3/Submit) id n9MI4QA3013295; Thu, 22 Oct 2009 14:04:26 -0400 Date: Thu, 22 Oct 2009 14:04:25 -0400 From: Hal Rosenstock To: sashak@voltaire.com Cc: linux-rdma@vger.kernel.org Subject: [PARCH][RESEND] opensm/osm_sa_mcmember_record.c: Validate P_Key on IPoIB signed MGIDs Message-ID: <20091022180425.GA13290@comcast.net> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) 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_sa_mcmember_record.c b/opensm/opensm/osm_sa_mcmember_record.c index dd01eed..a185238 100644 --- a/opensm/opensm/osm_sa_mcmember_record.c +++ b/opensm/opensm/osm_sa_mcmember_record.c @@ -3,6 +3,7 @@ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved. * Copyright (c) 1996-2003 Intel Corporation. All rights reserved. * Copyright (c) 2008 Xsigo Systems Inc. All rights reserved. + * Copyright (c) 2009 HNR Consulting. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU @@ -516,6 +517,7 @@ static ib_api_status_t validate_requested_mgid(IN osm_sa_t * sa, p_mcm_rec) { uint16_t signature; + ib_net16_t pkey; boolean_t valid = TRUE; OSM_LOG_ENTER(sa->p_log); @@ -555,6 +557,16 @@ static ib_api_status_t validate_requested_mgid(IN osm_sa_t * sa, * */ if (signature == 0x401B || signature == 0x601B) { + /* Validate P_Key portion of MGID per RFC 4391 */ + memcpy(&pkey, &(p_mcm_rec->mgid.raw[4]), sizeof(pkey)); + if (!ib_pkey_is_full_member(pkey) || ib_pkey_is_invalid(pkey)) { + OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B27: " + "MGID uses limited or invalid P_Key 0x%x\n", + cl_ntoh16(pkey)); + valid = FALSE; + goto Exit; + } + OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Skipping MGID Validation for IPoIB Signed (0x%04X) MGIDs\n", signature);