1
0
mirror of https://github.com/openbsd/src.git synced 2026-06-18 07:13:36 +02:00

Guard SIOCDELMULTI if_ioctl calls with KERNEL_LOCK() where the call is

made from socket close path. Most device drivers are not MP-safe yet,
and the closing of AF_INET and AF_INET6 sockets is no longer under the
kernel lock.

This fixes a panic seen by jcs@.

OK mpi@
This commit is contained in:
visa
2020-03-15 05:34:13 +00:00
parent 189d7e687c
commit 4b9a5ba932
4 changed files with 12 additions and 4 deletions
+3 -1
View File
@@ -1,4 +1,4 @@
/* $OpenBSD: in.c,v 1.168 2019/12/01 21:12:42 jca Exp $ */
/* $OpenBSD: in.c,v 1.169 2020/03/15 05:34:13 visa Exp $ */
/* $NetBSD: in.c,v 1.26 1996/02/13 23:41:39 christos Exp $ */
/*
@@ -929,7 +929,9 @@ in_delmulti(struct in_multi *inm)
sizeof(struct sockaddr_in);
satosin(&ifr.ifr_addr)->sin_family = AF_INET;
satosin(&ifr.ifr_addr)->sin_addr = inm->inm_addr;
KERNEL_LOCK();
(*ifp->if_ioctl)(ifp, SIOCDELMULTI, (caddr_t)&ifr);
KERNEL_UNLOCK();
TAILQ_REMOVE(&ifp->if_maddrlist, &inm->inm_ifma,
ifma_list);
+3 -1
View File
@@ -1,4 +1,4 @@
/* $OpenBSD: ip_mroute.c,v 1.128 2019/09/02 13:12:09 bluhm Exp $ */
/* $OpenBSD: ip_mroute.c,v 1.129 2020/03/15 05:34:13 visa Exp $ */
/* $NetBSD: ip_mroute.c,v 1.85 2004/04/26 01:31:57 matt Exp $ */
/*
@@ -772,7 +772,9 @@ vif_delete(struct ifnet *ifp)
satosin(&ifr.ifr_addr)->sin_len = sizeof(struct sockaddr_in);
satosin(&ifr.ifr_addr)->sin_family = AF_INET;
satosin(&ifr.ifr_addr)->sin_addr = zeroin_addr;
KERNEL_LOCK();
(*ifp->if_ioctl)(ifp, SIOCDELMULTI, (caddr_t)&ifr);
KERNEL_UNLOCK();
free(v, M_MRTABLE, sizeof(*v));
}
+3 -1
View File
@@ -1,4 +1,4 @@
/* $OpenBSD: in6.c,v 1.234 2019/11/18 22:08:59 bluhm Exp $ */
/* $OpenBSD: in6.c,v 1.235 2020/03/15 05:34:14 visa Exp $ */
/* $KAME: in6.c,v 1.372 2004/06/14 08:14:21 itojun Exp $ */
/*
@@ -1100,7 +1100,9 @@ in6_delmulti(struct in6_multi *in6m)
ifr.ifr_addr.sin6_len = sizeof(struct sockaddr_in6);
ifr.ifr_addr.sin6_family = AF_INET6;
ifr.ifr_addr.sin6_addr = in6m->in6m_addr;
KERNEL_LOCK();
(*ifp->if_ioctl)(ifp, SIOCDELMULTI, (caddr_t)&ifr);
KERNEL_UNLOCK();
TAILQ_REMOVE(&ifp->if_maddrlist, &in6m->in6m_ifma,
ifma_list);
+3 -1
View File
@@ -1,4 +1,4 @@
/* $OpenBSD: ip6_mroute.c,v 1.122 2019/09/04 16:13:49 bluhm Exp $ */
/* $OpenBSD: ip6_mroute.c,v 1.123 2020/03/15 05:34:14 visa Exp $ */
/* $NetBSD: ip6_mroute.c,v 1.59 2003/12/10 09:28:38 itojun Exp $ */
/* $KAME: ip6_mroute.c,v 1.45 2001/03/25 08:38:51 itojun Exp $ */
@@ -565,7 +565,9 @@ ip6_mrouter_detach(struct ifnet *ifp)
memset(&ifr, 0, sizeof(ifr));
ifr.ifr_addr.sin6_family = AF_INET6;
ifr.ifr_addr.sin6_addr = in6addr_any;
KERNEL_LOCK();
(*ifp->if_ioctl)(ifp, SIOCDELMULTI, (caddr_t)&ifr);
KERNEL_UNLOCK();
free(m6, M_MRTABLE, sizeof(*m6));
}