Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Nov 2009 16:00:41 +0000 (UTC)
From:      VANHULLEBUS Yvan <vanhu@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r199398 - head/sys/netipsec
Message-ID:  <200911171600.nAHG0f2e019707@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: vanhu
Date: Tue Nov 17 16:00:41 2009
New Revision: 199398
URL: http://svn.freebsd.org/changeset/base/199398

Log:
  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
  MFC after:	2w (MFC on 8 before 8.0 release ???)

Modified:
  head/sys/netipsec/key.c

Modified: head/sys/netipsec/key.c
==============================================================================
--- head/sys/netipsec/key.c	Tue Nov 17 15:59:26 2009	(r199397)
+++ head/sys/netipsec/key.c	Tue Nov 17 16:00:41 2009	(r199398)
@@ -2852,9 +2852,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__,
@@ -5698,8 +5699,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?200911171600.nAHG0f2e019707>