From: kn Date: Wed, 19 Apr 2023 20:03:51 +0000 (+0000) Subject: move kernel lock into multicast ioctl handlers; OK mvs X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=2a675d814334aded85c4bd058132e80ee7e1f5c2;p=openbsd move kernel lock into multicast ioctl handlers; OK mvs --- diff --git a/sys/netinet/in.c b/sys/netinet/in.c index 498cb2f6bd3..1cbfbef2976 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in.c,v 1.181 2023/04/18 22:20:16 kn Exp $ */ +/* $OpenBSD: in.c,v 1.182 2023/04/19 20:03:51 kn Exp $ */ /* $NetBSD: in.c,v 1.26 1996/02/13 23:41:39 christos Exp $ */ /* @@ -210,9 +210,7 @@ in_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp) #ifdef MROUTING case SIOCGETVIFCNT: case SIOCGETSGCNT: - KERNEL_LOCK(); error = mrt_ioctl(so, cmd, data); - KERNEL_UNLOCK(); break; #endif /* MROUTING */ default: diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c index 5b27d73fbef..3dd7dab22fe 100644 --- a/sys/netinet/ip_mroute.c +++ b/sys/netinet/ip_mroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_mroute.c,v 1.137 2022/09/08 10:22:06 kn Exp $ */ +/* $OpenBSD: ip_mroute.c,v 1.138 2023/04/19 20:03:51 kn Exp $ */ /* $NetBSD: ip_mroute.c,v 1.85 2004/04/26 01:31:57 matt Exp $ */ /* @@ -261,6 +261,8 @@ mrt_ioctl(struct socket *so, u_long cmd, caddr_t data) if (inp == NULL) return (ENOTCONN); + KERNEL_LOCK(); + if (so != ip_mrouter[inp->inp_rtableid]) error = EINVAL; else @@ -282,6 +284,7 @@ mrt_ioctl(struct socket *so, u_long cmd, caddr_t data) break; } + KERNEL_UNLOCK(); return (error); } diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c index a6b9bb72335..ea328b1b782 100644 --- a/sys/netinet6/in6.c +++ b/sys/netinet6/in6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6.c,v 1.259 2022/12/06 22:19:39 mvs Exp $ */ +/* $OpenBSD: in6.c,v 1.260 2023/04/19 20:03:52 kn Exp $ */ /* $KAME: in6.c,v 1.372 2004/06/14 08:14:21 itojun Exp $ */ /* @@ -207,9 +207,7 @@ in6_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp) #ifdef MROUTING case SIOCGETSGCNT_IN6: case SIOCGETMIFCNT_IN6: - KERNEL_LOCK(); error = mrt6_ioctl(so, cmd, data); - KERNEL_UNLOCK(); break; #endif /* MROUTING */ default: diff --git a/sys/netinet6/ip6_mroute.c b/sys/netinet6/ip6_mroute.c index e7078d0c1ad..bb805e50471 100644 --- a/sys/netinet6/ip6_mroute.c +++ b/sys/netinet6/ip6_mroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_mroute.c,v 1.135 2022/09/08 10:22:07 kn Exp $ */ +/* $OpenBSD: ip6_mroute.c,v 1.136 2023/04/19 20:03:52 kn 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 $ */ @@ -245,6 +245,8 @@ mrt6_ioctl(struct socket *so, u_long cmd, caddr_t data) if (inp == NULL) return (ENOTCONN); + KERNEL_LOCK(); + switch (cmd) { case SIOCGETSGCNT_IN6: NET_LOCK_SHARED(); @@ -262,6 +264,8 @@ mrt6_ioctl(struct socket *so, u_long cmd, caddr_t data) error = ENOTTY; break; } + + KERNEL_UNLOCK(); return error; }