Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/netipsec change locking order, to make sure the cpu is a...
details: https://anonhg.NetBSD.org/src/rev/04c10b16dfaf
branches: trunk
changeset: 762051:04c10b16dfaf
user: drochner <drochner%NetBSD.org@localhost>
date: Mon Feb 14 13:43:45 2011 +0000
description:
change locking order, to make sure the cpu is at splsoftnet()
before the softnet_lock (adaptive) mutex is acquired, from
Wolfgang Stukenbrock, should fix a recursive lock panic
diffstat:
sys/netipsec/xform_ah.c | 20 ++++++++++----------
sys/netipsec/xform_esp.c | 20 ++++++++++----------
sys/netipsec/xform_ipcomp.c | 20 ++++++++++----------
3 files changed, 30 insertions(+), 30 deletions(-)
diffs (276 lines):
diff -r a3159118f587 -r 04c10b16dfaf sys/netipsec/xform_ah.c
--- a/sys/netipsec/xform_ah.c Mon Feb 14 13:05:00 2011 +0000
+++ b/sys/netipsec/xform_ah.c Mon Feb 14 13:43:45 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xform_ah.c,v 1.27 2011/02/10 20:24:27 drochner Exp $ */
+/* $NetBSD: xform_ah.c,v 1.28 2011/02/14 13:43:45 drochner Exp $ */
/* $FreeBSD: src/sys/netipsec/xform_ah.c,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $ */
/* $OpenBSD: ip_ah.c,v 1.63 2001/06/26 06:18:58 angelos Exp $ */
/*
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.27 2011/02/10 20:24:27 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.28 2011/02/14 13:43:45 drochner Exp $");
#include "opt_inet.h"
#ifdef __FreeBSD__
@@ -829,8 +829,8 @@
}
#endif
+ s = splsoftnet();
mutex_enter(softnet_lock);
- s = splsoftnet();
sav = KEY_ALLOCSA(&tc->tc_dst, tc->tc_proto, tc->tc_spi, sport, dport);
if (sav == NULL) {
@@ -854,8 +854,8 @@
sav->tdb_cryptoid = crp->crp_sid;
if (crp->crp_etype == EAGAIN) {
+ mutex_exit(softnet_lock);
splx(s);
- mutex_exit(softnet_lock);
return crypto_dispatch(crp);
}
@@ -964,14 +964,14 @@
IPSEC_COMMON_INPUT_CB(m, sav, skip, protoff, mtag);
KEY_FREESAV(&sav);
+ mutex_exit(softnet_lock);
splx(s);
- mutex_exit(softnet_lock);
return error;
bad:
if (sav)
KEY_FREESAV(&sav);
+ mutex_exit(softnet_lock);
splx(s);
- mutex_exit(softnet_lock);
if (m != NULL)
m_freem(m);
if (tc != NULL)
@@ -1235,8 +1235,8 @@
ptr = (tc + 1);
m = (struct mbuf *) crp->crp_buf;
+ s = splsoftnet();
mutex_enter(softnet_lock);
- s = splsoftnet();
isr = tc->tc_isr;
sav = KEY_ALLOCSA(&tc->tc_dst, tc->tc_proto, tc->tc_spi, 0, 0);
@@ -1255,8 +1255,8 @@
if (crp->crp_etype == EAGAIN) {
KEY_FREESAV(&sav);
+ mutex_exit(softnet_lock);
splx(s);
- mutex_exit(softnet_lock);
return crypto_dispatch(crp);
}
@@ -1302,14 +1302,14 @@
/* NB: m is reclaimed by ipsec_process_done. */
err = ipsec_process_done(m, isr);
KEY_FREESAV(&sav);
+ mutex_exit(softnet_lock);
splx(s);
- mutex_exit(softnet_lock);
return err;
bad:
if (sav)
KEY_FREESAV(&sav);
+ mutex_exit(softnet_lock);
splx(s);
- mutex_exit(softnet_lock);
if (m)
m_freem(m);
free(tc, M_XDATA);
diff -r a3159118f587 -r 04c10b16dfaf sys/netipsec/xform_esp.c
--- a/sys/netipsec/xform_esp.c Mon Feb 14 13:05:00 2011 +0000
+++ b/sys/netipsec/xform_esp.c Mon Feb 14 13:43:45 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xform_esp.c,v 1.23 2011/02/10 20:24:27 drochner Exp $ */
+/* $NetBSD: xform_esp.c,v 1.24 2011/02/14 13:43:45 drochner Exp $ */
/* $FreeBSD: src/sys/netipsec/xform_esp.c,v 1.2.2.1 2003/01/24 05:11:36 sam Exp $ */
/* $OpenBSD: ip_esp.c,v 1.69 2001/06/26 06:18:59 angelos Exp $ */
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.23 2011/02/10 20:24:27 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.24 2011/02/14 13:43:45 drochner Exp $");
#include "opt_inet.h"
#ifdef __FreeBSD__
@@ -498,8 +498,8 @@
}
#endif
+ s = splsoftnet();
mutex_enter(softnet_lock);
- s = splsoftnet();
sav = KEY_ALLOCSA(&tc->tc_dst, tc->tc_proto, tc->tc_spi, sport, dport);
if (sav == NULL) {
@@ -528,8 +528,8 @@
if (crp->crp_etype == EAGAIN) {
KEY_FREESAV(&sav);
+ mutex_exit(softnet_lock);
splx(s);
- mutex_exit(softnet_lock);
return crypto_dispatch(crp);
}
@@ -667,14 +667,14 @@
IPSEC_COMMON_INPUT_CB(m, sav, skip, protoff, mtag);
KEY_FREESAV(&sav);
+ mutex_exit(softnet_lock);
splx(s);
- mutex_exit(softnet_lock);
return error;
bad:
if (sav)
KEY_FREESAV(&sav);
+ mutex_exit(softnet_lock);
splx(s);
- mutex_exit(softnet_lock);
if (m != NULL)
m_freem(m);
if (tc != NULL)
@@ -939,8 +939,8 @@
IPSEC_ASSERT(tc != NULL, ("esp_output_cb: null opaque data area!"));
m = (struct mbuf *) crp->crp_buf;
+ s = splsoftnet();
mutex_enter(softnet_lock);
- s = splsoftnet();
isr = tc->tc_isr;
sav = KEY_ALLOCSA(&tc->tc_dst, tc->tc_proto, tc->tc_spi, 0, 0);
@@ -963,8 +963,8 @@
if (crp->crp_etype == EAGAIN) {
KEY_FREESAV(&sav);
+ mutex_exit(softnet_lock);
splx(s);
- mutex_exit(softnet_lock);
return crypto_dispatch(crp);
}
@@ -1010,14 +1010,14 @@
/* NB: m is reclaimed by ipsec_process_done. */
err = ipsec_process_done(m, isr);
KEY_FREESAV(&sav);
+ mutex_exit(softnet_lock);
splx(s);
- mutex_exit(softnet_lock);
return err;
bad:
if (sav)
KEY_FREESAV(&sav);
+ mutex_exit(softnet_lock);
splx(s);
- mutex_exit(softnet_lock);
if (m)
m_freem(m);
free(tc, M_XDATA);
diff -r a3159118f587 -r 04c10b16dfaf sys/netipsec/xform_ipcomp.c
--- a/sys/netipsec/xform_ipcomp.c Mon Feb 14 13:05:00 2011 +0000
+++ b/sys/netipsec/xform_ipcomp.c Mon Feb 14 13:43:45 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xform_ipcomp.c,v 1.21 2011/02/10 20:24:27 drochner Exp $ */
+/* $NetBSD: xform_ipcomp.c,v 1.22 2011/02/14 13:43:45 drochner Exp $ */
/* $FreeBSD: src/sys/netipsec/xform_ipcomp.c,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $ */
/* $OpenBSD: ip_ipcomp.c,v 1.1 2001/07/05 12:08:52 jjbg Exp $ */
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xform_ipcomp.c,v 1.21 2011/02/10 20:24:27 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_ipcomp.c,v 1.22 2011/02/14 13:43:45 drochner Exp $");
/* IP payload compression protocol (IPComp), see RFC 2393 */
#include "opt_inet.h"
@@ -258,8 +258,8 @@
}
#endif
+ s = splsoftnet();
mutex_enter(softnet_lock);
- s = splsoftnet();
sav = KEY_ALLOCSA(&tc->tc_dst, tc->tc_proto, tc->tc_spi, sport, dport);
if (sav == NULL) {
@@ -283,8 +283,8 @@
if (crp->crp_etype == EAGAIN) {
KEY_FREESAV(&sav);
+ mutex_exit(softnet_lock);
splx(s);
- mutex_exit(softnet_lock);
return crypto_dispatch(crp);
}
@@ -342,14 +342,14 @@
IPSEC_COMMON_INPUT_CB(m, sav, skip, protoff, NULL);
KEY_FREESAV(&sav);
+ mutex_exit(softnet_lock);
splx(s);
- mutex_exit(softnet_lock);
return error;
bad:
if (sav)
KEY_FREESAV(&sav);
+ mutex_exit(softnet_lock);
splx(s);
- mutex_exit(softnet_lock);
if (m)
m_freem(m);
if (tc != NULL)
@@ -518,8 +518,8 @@
skip = tc->tc_skip;
rlen = crp->crp_ilen - skip;
+ s = splsoftnet();
mutex_enter(softnet_lock);
- s = splsoftnet();
isr = tc->tc_isr;
sav = KEY_ALLOCSA(&tc->tc_dst, tc->tc_proto, tc->tc_spi, 0, 0);
@@ -539,8 +539,8 @@
if (crp->crp_etype == EAGAIN) {
KEY_FREESAV(&sav);
+ mutex_exit(softnet_lock);
splx(s);
- mutex_exit(softnet_lock);
return crypto_dispatch(crp);
}
IPCOMP_STATINC(IPCOMP_STAT_NOXFORM);
@@ -635,14 +635,14 @@
/* NB: m is reclaimed by ipsec_process_done. */
error = ipsec_process_done(m, isr);
KEY_FREESAV(&sav);
+ mutex_exit(softnet_lock);
splx(s);
- mutex_exit(softnet_lock);
return error;
bad:
if (sav)
KEY_FREESAV(&sav);
+ mutex_exit(softnet_lock);
splx(s);
- mutex_exit(softnet_lock);
if (m)
m_freem(m);
free(tc, M_XDATA);
Home |
Main Index |
Thread Index |
Old Index