Skip to contentSkip to conversation

opensm/osm_sa_mcmember_record.c: Validate P_Key on IPoIB signed MGIDs

PATCH RESEND In review Hal Rosenstock 2 participants 2 messages Oct 22, 2009 – Oct 23, 2009 1 message not in the archive InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 opensm/osm_sa_mcmember_record.c: Validate P_Key on IPoIB signed MGIDs

Per RFC 4391 rules for P_Key portion of MGIDs needing to be full member and valid P_Key

---

opensm/opensm/osm_sa_mcmember_record.c +12 -0
index dd01eed..a185238 100644
@@ -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);

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 3 lines · Hal Rosenstock

Per RFC 4391 rules for P_Key portion of MGIDs needing to be full member and valid P_Key

Strictly speaking I cannot find in RFC a requirement about valid P_Key, even in MGID address example P_Key = 0x8000 is used there.

BTW what is the reason to be so restrictive here and preventing from not fully complaint guys to work?

And even if so, why such MGID shouldn't be qualified as "regular" (non IPoIB)? As far as I can see in the code the current behavior will take this approach.

Quoted 24 lines

---

opensm/opensm/osm_sa_mcmember_record.c +2 -0
index dd01eed..a185238 100644
@@ -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);

opensm/opensm/osm_sa_mcmember_record.c static ib_api_status_t validate_requested_mgid(IN osm_sa_t * sa, · line 563

Quoted 7 lines
opensm/opensm/osm_sa_mcmember_record.c +4 -0
@@ -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: "

This is a client's error, so we can reduce verbosity.

Sasha

opensm/opensm/osm_sa_mcmember_record.c static ib_api_status_t validate_requested_mgid(IN osm_sa_t * sa, · line 572

Quoted 10 lines
opensm/opensm/osm_sa_mcmember_record.c +6 -0
+				"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);

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html