From patchwork Thu Oct 22 14:59:46 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 55526 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 n9N5S8tG002544 for ; Fri, 23 Oct 2009 05:28:08 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751731AbZJWF2B (ORCPT ); Fri, 23 Oct 2009 01:28:01 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751727AbZJWF2B (ORCPT ); Fri, 23 Oct 2009 01:28:01 -0400 Received: from qmta02.westchester.pa.mail.comcast.net ([76.96.62.24]:58667 "EHLO QMTA02.westchester.pa.mail.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751120AbZJWF2B (ORCPT ); Fri, 23 Oct 2009 01:28:01 -0400 Received: from OMTA10.westchester.pa.mail.comcast.net ([76.96.62.28]) by QMTA02.westchester.pa.mail.comcast.net with comcast id vmiM1c0030cZkys52r1mot; Thu, 22 Oct 2009 15:01:46 +0000 Received: from hal.comcast.net ([75.69.247.31]) by OMTA10.westchester.pa.mail.comcast.net with comcast id vr1m1c0020hNrtn3Wr1mcU; Thu, 22 Oct 2009 15:01:46 +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 n9MF00Mc007966; Thu, 22 Oct 2009 11:00:05 -0400 Received: (from hnrose@localhost) by hal.comcast.net (8.14.3/8.14.3/Submit) id n9MExkgn007935; Thu, 22 Oct 2009 10:59:46 -0400 Date: Thu, 22 Oct 2009 10:59:46 -0400 From: Hal Rosenstock To: sashak@voltaire.com Cc: linux-rdma@vger.kernel.org Subject: [PATCH] opensm/osm_sa_mcmember_record.c: Validate P_Key on IPoIB signed MGIDs Message-ID: <20091022145946.GA7932@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);