All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jim Schutt" <jaschut-4OHPYypu0djtX7QSmKvirg@public.gmane.org>
To: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org,
	Jim Schutt <jaschut-4OHPYypu0djtX7QSmKvirg@public.gmane.org>
Subject: [PATCH v3 15/17] opensm: Avoid havoc in minhop caused by torus-2QoS persistent use of osm_port_t:priv.
Date: Tue, 15 Jun 2010 13:53:22 -0600	[thread overview]
Message-ID: <1276631604-29230-16-git-send-email-jaschut@sandia.gov> (raw)
In-Reply-To: <1276631604-29230-1-git-send-email-jaschut-4OHPYypu0djtX7QSmKvirg@public.gmane.org>

Torus-2QoS makes persistent use of osm_port_t:priv to speed calculation
of path SL values.

It cannot clear osm_port_t:priv members when it tears down its persistent
data for the following reason: If a port is removed from the fabric, the
opensm core will delete the corresponding osm_port_t object, leaving
torus-2QoS holding a dangling reference.  Torus-2QoS then has a use-after-free
error when tearing down its persistent data if it tries to use its dangling
osm_port_t reference to clear the priv member.

When torus-2QoS is unable to route a fabric due to missing switches and
opensm is configured to fall back to minhop, havoc will ensue because
minhop uses a non-NULL osm_port_t:priv as a proxy for LMC > 0: it
assumes if osm_port_t:priv is non-NULL it can only be because
alloc_ports_priv() has been called.

Fix this up by always calling alloc_ports_priv(), and have it set
priv = NULL if LMC == 0.

Signed-off-by: Jim Schutt <jaschut-4OHPYypu0djtX7QSmKvirg@public.gmane.org>
---
 opensm/opensm/osm_ucast_mgr.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/opensm/opensm/osm_ucast_mgr.c b/opensm/opensm/osm_ucast_mgr.c
index d1c485f..e6e40f0 100644
--- a/opensm/opensm/osm_ucast_mgr.c
+++ b/opensm/opensm/osm_ucast_mgr.c
@@ -315,8 +315,10 @@ static void alloc_ports_priv(osm_ucast_mgr_t * mgr)
 	     item = cl_qmap_next(item)) {
 		port = (osm_port_t *) item;
 		lmc = ib_port_info_get_lmc(&port->p_physp->port_info);
-		if (!lmc)
+		if (!lmc) {
+			port->priv = NULL;
 			continue;
+		}
 		r = malloc(sizeof(*r) + sizeof(r->guids[0]) * (1 << lmc));
 		if (!r) {
 			OSM_LOG(mgr->p_log, OSM_LOG_ERROR, "ERR 3A09: "
@@ -363,8 +365,7 @@ static void ucast_mgr_process_tbl(IN cl_map_item_t * p_map_item,
 	/* Initialize LIDs in buffer to invalid port number. */
 	memset(p_sw->new_lft, OSM_NO_PATH, p_sw->max_lid_ho + 1);
 
-	if (p_mgr->p_subn->opt.lmc)
-		alloc_ports_priv(p_mgr);
+	alloc_ports_priv(p_mgr);
 
 	/*
 	   Iterate through every port setting LID routes for each
@@ -381,8 +382,7 @@ static void ucast_mgr_process_tbl(IN cl_map_item_t * p_map_item,
 		}
 	}
 
-	if (p_mgr->p_subn->opt.lmc)
-		free_ports_priv(p_mgr);
+	free_ports_priv(p_mgr);
 
 	OSM_LOG_EXIT(p_mgr->p_log);
 }
-- 
1.6.2.2


--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2010-06-15 19:53 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-15 19:53 [PATCH v3 00/17] opensm: Add new torus routing engine: torus-2QoS Jim Schutt
     [not found] ` <1276631604-29230-1-git-send-email-jaschut-4OHPYypu0djtX7QSmKvirg@public.gmane.org>
2010-06-15 19:53   ` [PATCH v3 01/17] opensm: Prepare for routing engine input to path record SL lookup and SL2VL map setup Jim Schutt
     [not found]     ` <1276631604-29230-2-git-send-email-jaschut-4OHPYypu0djtX7QSmKvirg@public.gmane.org>
2010-07-07 17:06       ` Sasha Khapyorsky
2010-07-07 17:57         ` Jim Schutt
     [not found]           ` <1278525460.4812.22.camel-mgfCWIlwujvg4c9jKm7R2O1ftBKYq+Ku@public.gmane.org>
2010-07-07 21:03             ` Sasha Khapyorsky
2010-06-15 19:53   ` [PATCH v3 02/17] opensm: Allow the routing engine to influence SL2VL calculations Jim Schutt
2010-06-15 19:53   ` [PATCH v3 03/17] opensm: Allow the routing engine to participate in path SL calculations Jim Schutt
     [not found]     ` <1276631604-29230-4-git-send-email-jaschut-4OHPYypu0djtX7QSmKvirg@public.gmane.org>
2010-07-13 18:36       ` Sasha Khapyorsky
2010-07-13 20:12         ` Jim Schutt
2010-06-15 19:53   ` [PATCH v3 04/17] opensm: Track the minimum value in the fabric of data VLs supported Jim Schutt
2010-06-15 19:53   ` [PATCH v3 05/17] opensm: Add struct osm_routing_engine callback to build spanning trees for multicast Jim Schutt
2010-06-15 19:53   ` [PATCH v3 06/17] opensm: Make mcast_mgr_purge_tree() available outside osm_mcast_mgr.c Jim Schutt
2010-06-15 19:53   ` [PATCH v3 07/17] opensm: Add torus-2QoS routing engine, part 1 Jim Schutt
2010-06-15 19:53   ` [PATCH v3 09/17] opensm: Add torus-2QoS routing engine, part 3 Jim Schutt
2010-06-15 19:53   ` [PATCH v3 10/17] opensm: Update documentation to describe torus-2QoS Jim Schutt
2010-06-15 19:53   ` [PATCH v3 11/17] opensm: Enable torus-2QoS routing engine Jim Schutt
2010-06-15 19:53   ` [PATCH v3 12/17] opensm: Add opensm option to specify file name for extra torus-2QoS configuration information Jim Schutt
2010-06-15 19:53   ` [PATCH v3 13/17] opensm: Do not require -Q option for torus-2QoS routing engine Jim Schutt
2010-06-15 19:53   ` [PATCH v3 14/17] opensm: Make it possible to configure no fallback " Jim Schutt
2010-06-15 19:53   ` Jim Schutt [this message]
2010-06-15 19:53   ` [PATCH v3 16/17] opensm: Avoid havoc in dump_ucast_routes() caused by torus-2QoS persistent use of osm_port_t:priv Jim Schutt
2010-06-15 19:53   ` [PATCH v3 17/17] opensm: Cause status of unicast routing attempt to propogate to callers of osm_ucast_mgr_process() Jim Schutt
2010-06-16 14:11   ` [PATCH v3 08/17] opensm: Add new torus routing engine: torus-2QoS, part 2 Jim Schutt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1276631604-29230-16-git-send-email-jaschut@sandia.gov \
    --to=jaschut-4ohpyypu0djtx7qsmkvirg@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.