Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 19 Aug 2011 13:41:00 +0000 (UTC)
From:      VANHULLEBUS Yvan <vanhu@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r225011 - stable/8/sys/netipsec
Message-ID:  <201108191341.p7JDf0ph005971@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: vanhu
Date: Fri Aug 19 13:41:00 2011
New Revision: 225011
URL: http://svn.freebsd.org/changeset/base/225011

Log:
  MFC:
  fixed two race conditions when inserting/removing SAs via PFKey,
  which can both lead to a kernel panic when adding/removing quickly
  a lot of SAs.
  
  Obtained from:	NETASQ

Modified:
  stable/8/sys/netipsec/key.c
Directory Properties:
  stable/8/sys/   (props changed)

Modified: stable/8/sys/netipsec/key.c
==============================================================================
--- stable/8/sys/netipsec/key.c	Fri Aug 19 13:34:05 2011	(r225010)
+++ stable/8/sys/netipsec/key.c	Fri Aug 19 13:41:00 2011	(r225011)
@@ -2866,9 +2866,10 @@ key_newsav(m, mhp, sah, errp, where, tag
 	sa_initref(newsav);
 	newsav->state = SADB_SASTATE_LARVAL;
 
-	/* XXX locking??? */
+	SAHTREE_LOCK();
 	LIST_INSERT_TAIL(&sah->savtree[SADB_SASTATE_LARVAL], newsav,
 			secasvar, chain);
+	SAHTREE_UNLOCK();
 done:
 	KEYDEBUG(KEYDEBUG_IPSEC_STAMP,
 		printf("DP %s from %s:%u return SP:%p\n", __func__,
@@ -5712,8 +5713,8 @@ key_delete(so, m, mhp)
 	}
 
 	key_sa_chgstate(sav, SADB_SASTATE_DEAD);
-	SAHTREE_UNLOCK();
 	KEY_FREESAV(&sav);
+	SAHTREE_UNLOCK();
 
     {
 	struct mbuf *n;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201108191341.p7JDf0ph005971>