On 13/11/17(Mon) 12:33, Stuart Henderson wrote:
> On 2017/11/13 13:17, Martin Pieuchot wrote:
> > [...]
> > So it seems that two of your CPU end up looking at/dealing with
> > corrupted memory...
>
> Is that for sure? 2 does normally print a trace, 3 also drops into ddb.
But none of them print:
panic: spl assertion failure in soassertlocked.
However it might just be a race because the other CPU just entered panic
and set splassert_ctl to 0.
> Same after an hour or two uptime, but this time I get some "netlock:
> lock not held" from some cpu or other, and some functions in the bits of
> the trace that get displayed:
>
> login: panic: kernel diagnostic assertion "_kernel_lock_held()" failed: file
> "/src/cvs-openbsd/sys/kern/uipc_socket2.c", line 310
> Starting stack trace...
> panic() at panic+0x11b
> __assert(ffffffff812105d4,ffff80001f898a70,ffffff0063dc5b00,ffffff0061804318)
> at __assert+0x24
> sbappendaddr(0,ffffff0061804318,ffffff005fca5600,0,ffffff0063dc5b00) at
> sbappendaddrpanic: netlock: lock not held
Does the diff below help? It should in any case reduce the "netlock:
lock not held" noises.
Index: net/pfkeyv2.c
===================================================================
RCS file: /cvs/src/sys/net/pfkeyv2.c,v
retrieving revision 1.173
diff -u -p -r1.173 pfkeyv2.c
--- net/pfkeyv2.c 12 Nov 2017 14:11:15 -0000 1.173
+++ net/pfkeyv2.c 13 Nov 2017 12:57:36 -0000
@@ -428,12 +428,14 @@ pfkeyv2_sendmessage(void **headers, int
* Search for promiscuous listeners, skipping the
* original destination.
*/
+ KERNEL_LOCK();
LIST_FOREACH(s, &pfkeyv2_sockets, kcb_list) {
if ((s->flags & PFKEYV2_SOCKETFLAGS_PROMISC) &&
(s->rcb.rcb_socket != so) &&
(s->rdomain == rdomain))
pfkey_sendup(s, packet, 1);
}
+ KERNEL_UNLOCK();
m_freem(packet);
break;
@@ -442,6 +444,7 @@ pfkeyv2_sendmessage(void **headers, int
* Send the message to all registered sockets that match
* the specified satype (e.g., all IPSEC-ESP negotiators)
*/
+ KERNEL_LOCK();
LIST_FOREACH(s, &pfkeyv2_sockets, kcb_list) {
if ((s->flags & PFKEYV2_SOCKETFLAGS_REGISTERED) &&
(s->rdomain == rdomain)) {
@@ -454,6 +457,7 @@ pfkeyv2_sendmessage(void **headers, int
}
}
}
+ KERNEL_UNLOCK();
/* Free last/original copy of the packet */
m_freem(packet);
@@ -472,21 +476,25 @@ pfkeyv2_sendmessage(void **headers, int
goto ret;
/* Send to all registered promiscuous listeners */
+ KERNEL_LOCK();
LIST_FOREACH(s, &pfkeyv2_sockets, kcb_list) {
if ((s->flags & PFKEYV2_SOCKETFLAGS_PROMISC) &&
!(s->flags & PFKEYV2_SOCKETFLAGS_REGISTERED) &&
(s->rdomain == rdomain))
pfkey_sendup(s, packet, 1);
}
+ KERNEL_UNLOCK();
m_freem(packet);
break;
case PFKEYV2_SENDMESSAGE_BROADCAST:
/* Send message to all sockets */
+ KERNEL_LOCK();
LIST_FOREACH(s, &pfkeyv2_sockets, kcb_list) {
if (s->rdomain == rdomain)
pfkey_sendup(s, packet, 1);
}
+ KERNEL_UNLOCK();
m_freem(packet);
break;
}
@@ -1010,11 +1018,13 @@ pfkeyv2_send(struct socket *so, void *me
goto ret;
/* Send to all promiscuous listeners */
+ KERNEL_LOCK();
LIST_FOREACH(bkp, &pfkeyv2_sockets, kcb_list) {
if ((bkp->flags & PFKEYV2_SOCKETFLAGS_PROMISC) &&
(bkp->rdomain == rdomain))
pfkey_sendup(bkp, packet, 1);
}
+ KERNEL_UNLOCK();
m_freem(packet);
@@ -1788,12 +1798,15 @@ pfkeyv2_send(struct socket *so, void *me
if ((rval = pfdatatopacket(message, len, &packet)) != 0)
goto ret;
- LIST_FOREACH(bkp, &pfkeyv2_sockets, kcb_list)
+ KERNEL_LOCK();
+ LIST_FOREACH(bkp, &pfkeyv2_sockets, kcb_list) {
if ((bkp != kp) &&
(bkp->rdomain == rdomain) &&
(!smsg->sadb_msg_seq ||
(smsg->sadb_msg_seq == kp->pid)))
pfkey_sendup(bkp, packet, 1);
+ }
+ KERNEL_UNLOCK();
m_freem(packet);
} else {
Index: sys/systm.h
===================================================================
RCS file: /cvs/src/sys/sys/systm.h,v
retrieving revision 1.134
diff -u -p -r1.134 systm.h
--- sys/systm.h 10 Nov 2017 08:55:49 -0000 1.134
+++ sys/systm.h 13 Nov 2017 12:58:22 -0000
@@ -307,14 +307,14 @@ extern struct rwlock netlock;
#define NET_ASSERT_WLOCKED()
\
do { \
int _s = rw_status(&netlock); \
- if (_s != RW_WRITE) \
+ if ((splassert_ctl > 0) && (_s != RW_WRITE)) \
splassert_fail(RW_WRITE, _s, __func__); \
} while (0)
#define NET_ASSERT_WUNLOCKED()
\
do { \
int _s = rw_status(&netlock); \
- if (_s == RW_WRITE) \
+ if ((splassert_ctl > 0) && (_s == RW_WRITE)) \
splassert_fail(0, RW_WRITE, __func__); \
} while (0)
@@ -324,7 +324,7 @@ do {
\
#define NET_ASSERT_LOCKED()
\
do { \
int _s = rw_status(&netlock); \
- if (_s != RW_WRITE && _s != RW_READ) \
+ if ((splassert_ctl > 0) && (_s != RW_WRITE && _s != RW_READ)) \
splassert_fail(RW_READ, _s, __func__); \
} while (0)