Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Make sure *(if_output)() is called with KERNEL_LOCK held.
details: https://anonhg.NetBSD.org/src/rev/d6f5c79a9430
branches: trunk
changeset: 329183:d6f5c79a9430
user: bouyer <bouyer%NetBSD.org@localhost>
date: Tue May 13 19:36:16 2014 +0000
description:
Make sure *(if_output)() is called with KERNEL_LOCK held.
Add some KASSERT for this.
See http://mail-index.netbsd.org/tech-net/2014/04/09/msg004511.html
for details.
diffstat:
sys/external/bsd/ipf/netinet/ip_fil_netbsd.c | 8 ++++++--
sys/net/if_ethersubr.c | 6 ++++--
sys/net/if_loop.c | 6 ++++--
sys/net/if_vlan.c | 6 ++++--
sys/netinet/ip_carp.c | 24 ++++++++++++++++++++----
5 files changed, 38 insertions(+), 12 deletions(-)
diffs (246 lines):
diff -r c1bec2ba3204 -r d6f5c79a9430 sys/external/bsd/ipf/netinet/ip_fil_netbsd.c
--- a/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c Tue May 13 19:14:05 2014 +0000
+++ b/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c Tue May 13 19:36:16 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ip_fil_netbsd.c,v 1.8 2014/03/16 05:20:30 dholland Exp $ */
+/* $NetBSD: ip_fil_netbsd.c,v 1.9 2014/05/13 19:36:16 bouyer Exp $ */
/*
* Copyright (C) 2012 by Darren Reed.
@@ -8,7 +8,7 @@
#if !defined(lint)
#if defined(__NetBSD__)
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_fil_netbsd.c,v 1.8 2014/03/16 05:20:30 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_fil_netbsd.c,v 1.9 2014/05/13 19:36:16 bouyer Exp $");
#else
static const char sccsid[] = "@(#)ip_fil.c 2.41 6/5/96 (C) 1993-2000 Darren Reed";
static const char rcsid[] = "@(#)Id: ip_fil_netbsd.c,v 1.1.1.2 2012/07/22 13:45:17 darrenr Exp";
@@ -1209,7 +1209,9 @@
ip->ip_sum = in_cksum(m, hlen);
# endif /* M_CSUM_IPv4 */
+ KERNEL_LOCK(1, NULL);
error = (*ifp->if_output)(ifp, m, dst, rt);
+ KERNEL_UNLOCK_ONE(NULL);
goto done;
}
@@ -1296,7 +1298,9 @@
m0 = m->m_act;
m->m_act = 0;
if (error == 0) {
+ KERNEL_LOCK(1, NULL);
error = (*ifp->if_output)(ifp, m, dst, rt);
+ KERNEL_UNLOCK_ONE(NULL);
} else {
FREE_MB_T(m);
}
diff -r c1bec2ba3204 -r d6f5c79a9430 sys/net/if_ethersubr.c
--- a/sys/net/if_ethersubr.c Tue May 13 19:14:05 2014 +0000
+++ b/sys/net/if_ethersubr.c Tue May 13 19:36:16 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ethersubr.c,v 1.196 2014/02/25 22:42:06 pooka Exp $ */
+/* $NetBSD: if_ethersubr.c,v 1.197 2014/05/13 19:36:16 bouyer Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.196 2014/02/25 22:42:06 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.197 2014/05/13 19:36:16 bouyer Exp $");
#include "opt_inet.h"
#include "opt_atalk.h"
@@ -211,6 +211,8 @@
struct at_ifaddr *aa;
#endif /* NETATALK */
+ KASSERT(KERNEL_LOCKED_P());
+
#ifdef MBUFTRACE
m_claimm(m, ifp->if_mowner);
#endif
diff -r c1bec2ba3204 -r d6f5c79a9430 sys/net/if_loop.c
--- a/sys/net/if_loop.c Tue May 13 19:14:05 2014 +0000
+++ b/sys/net/if_loop.c Tue May 13 19:36:16 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_loop.c,v 1.76 2013/03/01 18:25:56 joerg Exp $ */
+/* $NetBSD: if_loop.c,v 1.77 2014/05/13 19:36:16 bouyer Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.76 2013/03/01 18:25:56 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.77 2014/05/13 19:36:16 bouyer Exp $");
#include "opt_inet.h"
#include "opt_atalk.h"
@@ -216,6 +216,8 @@
int csum_flags;
MCLAIM(m, ifp->if_mowner);
+ KASSERT(KERNEL_LOCKED_P());
+
if ((m->m_flags & M_PKTHDR) == 0)
panic("looutput: no header mbuf");
if (ifp->if_flags & IFF_LOOPBACK)
diff -r c1bec2ba3204 -r d6f5c79a9430 sys/net/if_vlan.c
--- a/sys/net/if_vlan.c Tue May 13 19:14:05 2014 +0000
+++ b/sys/net/if_vlan.c Tue May 13 19:36:16 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_vlan.c,v 1.69 2011/10/19 22:07:09 dyoung Exp $ */
+/* $NetBSD: if_vlan.c,v 1.70 2014/05/13 19:36:16 bouyer Exp $ */
/*-
* Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@@ -78,7 +78,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.69 2011/10/19 22:07:09 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.70 2014/05/13 19:36:16 bouyer Exp $");
#include "opt_inet.h"
@@ -681,6 +681,8 @@
int error;
ALTQ_DECL(struct altq_pktattr pktattr;)
+ KASSERT(KERNEL_LOCKED_P());
+
ifp->if_flags |= IFF_OACTIVE;
for (;;) {
diff -r c1bec2ba3204 -r d6f5c79a9430 sys/netinet/ip_carp.c
--- a/sys/netinet/ip_carp.c Tue May 13 19:14:05 2014 +0000
+++ b/sys/netinet/ip_carp.c Tue May 13 19:36:16 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ip_carp.c,v 1.53 2014/04/04 12:53:04 bouyer Exp $ */
+/* $NetBSD: ip_carp.c,v 1.54 2014/05/13 19:36:16 bouyer Exp $ */
/* $OpenBSD: ip_carp.c,v 1.113 2005/11/04 08:11:54 mcbride Exp $ */
/*
@@ -31,7 +31,7 @@
#include "opt_mbuftrace.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.53 2014/04/04 12:53:04 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.54 2014/05/13 19:36:16 bouyer Exp $");
/*
* TODO:
@@ -355,6 +355,7 @@
struct ifaddr *ifa;
int s;
+ KERNEL_LOCK(1, NULL);
s = splsoftnet();
IFADDR_FOREACH(ifa, &sc->sc_if) {
switch (ifa->ifa_addr->sa_family) {
@@ -452,6 +453,7 @@
}
}
splx(s);
+ KERNEL_UNLOCK_ONE(NULL);
}
/*
@@ -866,6 +868,7 @@
carp_setrun(sc, 0);
carp_multicast_cleanup(sc);
+ KERNEL_LOCK(1, NULL);
s = splnet();
if (sc->sc_carpdev != NULL) {
/* XXX linkstatehook removal */
@@ -879,6 +882,7 @@
}
sc->sc_carpdev = NULL;
splx(s);
+ KERNEL_UNLOCK_ONE(NULL);
}
/* Detach an interface from the carp. */
@@ -945,6 +949,7 @@
struct ifaddr *ifa;
struct sockaddr sa;
+ KERNEL_LOCK(1, NULL);
s = splsoftnet();
advbase = advskew = 0; /* Sssssh compiler */
@@ -1147,6 +1152,7 @@
retry_later:
splx(s);
+ KERNEL_UNLOCK_ONE(NULL);
if (advbase != 255 || advskew != 255)
callout_schedule(&sc->sc_ad_tmo, tvtohz(&tv));
}
@@ -1161,8 +1167,10 @@
{
struct ifaddr *ifa;
struct in_addr *in;
- int s = splsoftnet();
+ int s;
+ KERNEL_LOCK(1, NULL);
+ s = splsoftnet();
IFADDR_FOREACH(ifa, &sc->sc_if) {
if (ifa->ifa_addr->sa_family != AF_INET)
@@ -1172,6 +1180,7 @@
arprequest(sc->sc_carpdev, in, in, CLLADDR(sc->sc_if.if_sadl));
}
splx(s);
+ KERNEL_UNLOCK_ONE(NULL);
}
#ifdef INET6
@@ -1181,7 +1190,10 @@
struct ifaddr *ifa;
struct in6_addr *in6;
static struct in6_addr mcast = IN6ADDR_LINKLOCAL_ALLNODES_INIT;
- int s = splsoftnet();
+ int s;
+
+ KERNEL_LOCK(1, NULL);
+ s = splsoftnet();
IFADDR_FOREACH(ifa, &sc->sc_if) {
@@ -1193,6 +1205,7 @@
ND_NA_FLAG_OVERRIDE, 1, NULL);
}
splx(s);
+ KERNEL_UNLOCK_ONE(NULL);
}
#endif /* INET6 */
@@ -1605,10 +1618,12 @@
if (sc->sc_naddrs || sc->sc_naddrs6)
sc->sc_if.if_flags |= IFF_UP;
carp_set_enaddr(sc);
+ KERNEL_LOCK(1, NULL);
s = splnet();
/* XXX linkstatehooks establish */
carp_carpdev_state(ifp);
splx(s);
+ KERNEL_UNLOCK_ONE(NULL);
} else {
carpdetach(sc);
sc->sc_if.if_flags &= ~(IFF_UP|IFF_RUNNING);
@@ -2072,6 +2087,7 @@
struct rtentry *rt)
{
struct carp_softc *sc = ((struct carp_softc *)ifp->if_softc);
+ KASSERT(KERNEL_LOCKED_P());
if (sc->sc_carpdev != NULL && sc->sc_state == MASTER) {
return (sc->sc_carpdev->if_output(ifp, m, sa, rt));
Home |
Main Index |
Thread Index |
Old Index