diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2016-09-27 18:41:12 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2016-09-27 18:41:12 +0000 |
commit | 7a0f5d4ccf73b4587000f913b71563ed56bbf1f4 (patch) | |
tree | 899e05b9818d9fb0f9d5620a4de08fbec0fdd05b /sys | |
parent | 8699d46055700f009a2a09cc300c0cfa63164dd5 (diff) |
Protect sbappendaddr() and sorwakeup() with splsoftnet in
rt_senddesync(). This fixes a splassert warning seen by sthen@.
Problem found by David Hill; OK sthen@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/net/rtsock.c | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index dd1e7643f27..673897796e4 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtsock.c,v 1.206 2016/09/24 19:27:10 phessler Exp $ */ +/* $OpenBSD: rtsock.c,v 1.207 2016/09/27 18:41:11 bluhm Exp $ */ /* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */ /* @@ -302,28 +302,34 @@ rt_senddesync(void *data) struct rawcb *rp; struct routecb *rop; struct mbuf *desync_mbuf; + int s; rp = (struct rawcb *)data; rop = (struct routecb *)rp; /* If we are in a DESYNC state, try to send a RTM_DESYNC packet */ - if ((rop->flags & ROUTECB_FLAG_DESYNC) != 0) { - /* - * If we fail to alloc memory or if sbappendaddr() - * fails, re-add timeout and try again. - */ - desync_mbuf = rt_msg1(RTM_DESYNC, NULL); - if ((desync_mbuf != NULL) && - (sbappendaddr(&rp->rcb_socket->so_rcv, &route_src, - desync_mbuf, (struct mbuf *)NULL) != 0)) { + if ((rop->flags & ROUTECB_FLAG_DESYNC) == 0) + return; + + /* + * If we fail to alloc memory or if sbappendaddr() + * fails, re-add timeout and try again. + */ + desync_mbuf = rt_msg1(RTM_DESYNC, NULL); + if (desync_mbuf != NULL) { + s = splsoftnet(); + if (sbappendaddr(&rp->rcb_socket->so_rcv, &route_src, + desync_mbuf, NULL) != 0) { rop->flags &= ~ROUTECB_FLAG_DESYNC; sorwakeup(rp->rcb_socket); - } else { - m_freem(desync_mbuf); - /* Re-add timeout to try sending msg again */ - timeout_add(&rop->timeout, ROUTE_DESYNC_RESEND_TIMEOUT); + splx(s); + return; } + splx(s); + m_freem(desync_mbuf); } + /* Re-add timeout to try sending msg again */ + timeout_add(&rop->timeout, ROUTE_DESYNC_RESEND_TIMEOUT); } void |