summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2017-05-18 14:48:28 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2017-05-18 14:48:28 +0000
commit52fc3c04d95132c0a30c5508febc9d630b4c71b1 (patch)
treebac8c1102a3fa2cff6e87499d854df8c3ae20970 /sys/dev
parent9e82e5ff88a8faee0e00ac7aa1b92aac4f06c440 (diff)
Grab the netlock in umb_state_task() and umb_decode_ip_configuration()
when calling in_ioctl(). These ioctls modify the routing table, which is global. So they need the lock. Found with Zaur Molotnikov's static lock analyzer. OK gerhard@ mpi@
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/usb/if_umb.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/sys/dev/usb/if_umb.c b/sys/dev/usb/if_umb.c
index 2e09c6d54c3..a7843ab0375 100644
--- a/sys/dev/usb/if_umb.c
+++ b/sys/dev/usb/if_umb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_umb.c,v 1.12 2017/05/03 15:32:31 gerhard Exp $ */
+/* $OpenBSD: if_umb.c,v 1.13 2017/05/18 14:48:27 bluhm Exp $ */
/*
* Copyright (c) 2016 genua mbH
@@ -949,7 +949,7 @@ umb_state_task(void *arg)
struct ifnet *ifp = GET_IFP(sc);
struct ifreq ifr;
struct in_aliasreq ifra;
- int s;
+ int s, ns;
int state;
s = splnet();
@@ -973,6 +973,7 @@ umb_state_task(void *arg)
*/
memset(sc->sc_info.ipv4dns, 0,
sizeof (sc->sc_info.ipv4dns));
+ NET_LOCK(ns);
if (in_ioctl(SIOCGIFADDR, (caddr_t)&ifr, ifp, 1) == 0 &&
satosin(&ifr.ifr_addr)->sin_addr.s_addr !=
INADDR_ANY) {
@@ -981,6 +982,7 @@ umb_state_task(void *arg)
sizeof (ifra.ifra_addr));
in_ioctl(SIOCDIFADDR, (caddr_t)&ifra, ifp, 1);
}
+ NET_UNLOCK(ns);
}
if_link_state_change(ifp);
}
@@ -1613,7 +1615,7 @@ umb_decode_ip_configuration(struct umb_softc *sc, void *data, int len)
{
struct mbim_cid_ip_configuration_info *ic = data;
struct ifnet *ifp = GET_IFP(sc);
- int s;
+ int s, ns;
uint32_t avail;
uint32_t val;
int n, i;
@@ -1667,7 +1669,10 @@ umb_decode_ip_configuration(struct umb_softc *sc, void *data, int len)
sin->sin_len = sizeof (ifra.ifra_mask);
in_len2mask(&sin->sin_addr, ipv4elem.prefixlen);
- if ((rv = in_ioctl(SIOCAIFADDR, (caddr_t)&ifra, ifp, 1)) == 0) {
+ NET_LOCK(ns);
+ rv = in_ioctl(SIOCAIFADDR, (caddr_t)&ifra, ifp, 1);
+ NET_UNLOCK(ns);
+ if (rv == 0) {
if (ifp->if_flags & IFF_DEBUG)
log(LOG_INFO, "%s: IPv4 addr %s, mask %s, "
"gateway %s\n", DEVNAM(ifp->if_softc),