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 ???)
This commit is contained in:
VANHULLEBUS Yvan 2009-11-17 16:00:41 +00:00
parent e266aa9ef4
commit 3e6265f14d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=199398

View File

@ -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;