diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2018-06-21 07:40:44 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2018-06-21 07:40:44 +0000 |
commit | fbd52449e1c7e51b398dba735b0f308f84ca76c7 (patch) | |
tree | a2f725863bb4d18b69d56ac898ec138c16a69012 /sys | |
parent | 3a21859a0c4c8bde27939cc91e4704e1d67f0ee5 (diff) |
Grab the KERNEL_LOCK() rather than asserting that it is held.
Prevent a panic now that some syscall are running unlocked.
Found the hardway by Gregor Best.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/net/if.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index 31d140e67cc..0d239d36be0 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.555 2018/06/18 12:13:10 mpi Exp $ */ +/* $OpenBSD: if.c,v 1.556 2018/06/21 07:40:43 mpi Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -1379,8 +1379,8 @@ ifa_ifwithaddr(struct sockaddr *addr, u_int rtableid) struct ifaddr *ifa; u_int rdomain; - KERNEL_ASSERT_LOCKED(); rdomain = rtable_l2(rtableid); + KERNEL_LOCK(); TAILQ_FOREACH(ifp, &ifnet, if_list) { if (ifp->if_rdomain != rdomain) continue; @@ -1389,10 +1389,13 @@ ifa_ifwithaddr(struct sockaddr *addr, u_int rtableid) if (ifa->ifa_addr->sa_family != addr->sa_family) continue; - if (equal(addr, ifa->ifa_addr)) + if (equal(addr, ifa->ifa_addr)) { + KERNEL_UNLOCK(); return (ifa); + } } } + KERNEL_UNLOCK(); return (NULL); } @@ -1405,8 +1408,8 @@ ifa_ifwithdstaddr(struct sockaddr *addr, u_int rdomain) struct ifnet *ifp; struct ifaddr *ifa; - KERNEL_ASSERT_LOCKED(); rdomain = rtable_l2(rdomain); + KERNEL_LOCK(); TAILQ_FOREACH(ifp, &ifnet, if_list) { if (ifp->if_rdomain != rdomain) continue; @@ -1415,11 +1418,14 @@ ifa_ifwithdstaddr(struct sockaddr *addr, u_int rdomain) if (ifa->ifa_addr->sa_family != addr->sa_family || ifa->ifa_dstaddr == NULL) continue; - if (equal(addr, ifa->ifa_dstaddr)) + if (equal(addr, ifa->ifa_dstaddr)) { + KERNEL_UNLOCK(); return (ifa); + } } } } + KERNEL_UNLOCK(); return (NULL); } |