Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-6]: src/sys Pull up following revision(s) (requested by bouyer in...



details:   https://anonhg.NetBSD.org/src/rev/c7747724a09a
branches:  netbsd-6
changeset: 776646:c7747724a09a
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Tue Jun 03 15:34:00 2014 +0000

description:
Pull up following revision(s) (requested by bouyer in ticket #1067):
        sys/dist/ipf/netinet/ip_fil_netbsd.c    1.9 via patch
        sys/net/if_ethersubr.c                  1.197 via patch
        sys/net/if_loop.c                       1.77 via patch
        sys/net/if_vlan.c                       1.70 via patch
        sys/netinet/if_arp.c                    1.158
        sys/netinet/ip_carp.c                   1.54 via patch
        sys/netinet6/ip6_flow.c                 1.23 via patch
        sys/netinet6/nd6.c                      1.150 via patch
        sys/rump/librump/rumpkern/klock.c       1.4

Make sure *(if_output)() is called with KERNEL_LOCK held to avoid mbuf leak.
See http://mail-index.netbsd.org/tech-net/2014/04/09/msg004511.html
for details. For netinet6, the problem report, fix and test were done
by njoly@ on current-users@

diffstat:

 sys/dist/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/if_arp.c                 |   8 +++++---
 sys/netinet/ip_carp.c                |  24 ++++++++++++++++++++----
 sys/netinet6/ip6_flow.c              |   7 ++++---
 sys/netinet6/nd6.c                   |  12 ++++++++----
 sys/rump/librump/rumpkern/klock.c    |  11 +++++++++--
 9 files changed, 64 insertions(+), 24 deletions(-)

diffs (truncated from 386 to 300 lines):

diff -r d13934b956d5 -r c7747724a09a sys/dist/ipf/netinet/ip_fil_netbsd.c
--- a/sys/dist/ipf/netinet/ip_fil_netbsd.c      Tue Jun 03 15:26:33 2014 +0000
+++ b/sys/dist/ipf/netinet/ip_fil_netbsd.c      Tue Jun 03 15:34:00 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_fil_netbsd.c,v 1.61.2.1 2013/02/08 19:54:45 riz Exp $       */
+/*     $NetBSD: ip_fil_netbsd.c,v 1.61.2.2 2014/06/03 15:34:00 msaitoh Exp $   */
 
 /*
  * Copyright (C) 1993-2003 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.61.2.1 2013/02/08 19:54:45 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_fil_netbsd.c,v 1.61.2.2 2014/06/03 15:34:00 msaitoh 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 2.55.2.67 2009/12/19 05:41:08 darrenr Exp";
@@ -1377,11 +1377,13 @@
                if (!ip->ip_sum)
                        ip->ip_sum = in_cksum(m, hlen);
 # endif /* M_CSUM_IPv4 */
+               KERNEL_LOCK(1, NULL);
 # if __NetBSD_Version__ >= 499001100
                error = (*ifp->if_output)(ifp, m, dst, rt);
 # else
                error = (*ifp->if_output)(ifp, m, (struct sockaddr *)dst, rt);
 # endif
+               KERNEL_UNLOCK_ONE(NULL);
                if (i) {
                        ip->ip_len = ntohs(ip->ip_len);
                        ip->ip_off = ntohs(ip->ip_off);
@@ -1471,6 +1473,7 @@
        for (m = m0; m; m = m0) {
                m0 = m->m_act;
                m->m_act = 0;
+               KERNEL_LOCK(1, NULL);
 # if __NetBSD_Version__ >= 499001100
                if (error == 0)
                        error = (*ifp->if_output)(ifp, m, dst, rt);
@@ -1483,6 +1486,7 @@
                else
                        FREE_MB_T(m);
 # endif
+               KERNEL_UNLOCK_ONE(NULL);
        }
     }
 done:
diff -r d13934b956d5 -r c7747724a09a sys/net/if_ethersubr.c
--- a/sys/net/if_ethersubr.c    Tue Jun 03 15:26:33 2014 +0000
+++ b/sys/net/if_ethersubr.c    Tue Jun 03 15:34:00 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ethersubr.c,v 1.188.8.3 2012/10/31 16:07:46 riz Exp $       */
+/*     $NetBSD: if_ethersubr.c,v 1.188.8.4 2014/06/03 15:34:00 msaitoh 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.188.8.3 2012/10/31 16:07:46 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.188.8.4 2014/06/03 15:34:00 msaitoh Exp $");
 
 #include "opt_inet.h"
 #include "opt_atalk.h"
@@ -222,6 +222,8 @@
        struct at_ifaddr *aa;
 #endif /* NETATALK */
 
+       KASSERT(KERNEL_LOCKED_P());
+
 #ifdef MBUFTRACE
        m_claimm(m, ifp->if_mowner);
 #endif
diff -r d13934b956d5 -r c7747724a09a sys/net/if_loop.c
--- a/sys/net/if_loop.c Tue Jun 03 15:26:33 2014 +0000
+++ b/sys/net/if_loop.c Tue Jun 03 15:34:00 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_loop.c,v 1.75 2011/06/20 09:43:27 kefren Exp $      */
+/*     $NetBSD: if_loop.c,v 1.75.8.1 2014/06/03 15:34:00 msaitoh 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.75 2011/06/20 09:43:27 kefren Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.75.8.1 2014/06/03 15:34:00 msaitoh Exp $");
 
 #include "opt_inet.h"
 #include "opt_atalk.h"
@@ -222,6 +222,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 d13934b956d5 -r c7747724a09a sys/net/if_vlan.c
--- a/sys/net/if_vlan.c Tue Jun 03 15:26:33 2014 +0000
+++ b/sys/net/if_vlan.c Tue Jun 03 15:34:00 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.69.8.1 2014/06/03 15:34:00 msaitoh 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.69.8.1 2014/06/03 15:34:00 msaitoh 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 d13934b956d5 -r c7747724a09a sys/netinet/if_arp.c
--- a/sys/netinet/if_arp.c      Tue Jun 03 15:26:33 2014 +0000
+++ b/sys/netinet/if_arp.c      Tue Jun 03 15:34:00 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_arp.c,v 1.154 2012/01/02 22:17:11 liamjfoy Exp $    */
+/*     $NetBSD: if_arp.c,v 1.154.2.1 2014/06/03 15:34:00 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.154 2012/01/02 22:17:11 liamjfoy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.154.2.1 2014/06/03 15:34:00 msaitoh Exp $");
 
 #include "opt_ddb.h"
 #include "opt_inet.h"
@@ -1480,8 +1480,10 @@
        sa.sa_family = AF_ARP;
        sa.sa_len = 2;
        m->m_flags |= M_BCAST;
+
+       KERNEL_LOCK(1, NULL);
        (*ifp->if_output)(ifp, m, &sa, NULL);
-
+       KERNEL_UNLOCK_ONE(NULL);
 }
 
 /*
diff -r d13934b956d5 -r c7747724a09a sys/netinet/ip_carp.c
--- a/sys/netinet/ip_carp.c     Tue Jun 03 15:26:33 2014 +0000
+++ b/sys/netinet/ip_carp.c     Tue Jun 03 15:34:00 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_carp.c,v 1.47.4.2 2014/04/11 08:52:14 msaitoh Exp $ */
+/*     $NetBSD: ip_carp.c,v 1.47.4.3 2014/06/03 15:34:00 msaitoh 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.47.4.2 2014/04/11 08:52:14 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.47.4.3 2014/06/03 15:34:00 msaitoh 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);
 }
 
 /*
@@ -867,6 +869,7 @@
        carp_setrun(sc, 0);
        carp_multicast_cleanup(sc);
 
+       KERNEL_LOCK(1, NULL);
        s = splnet();
        if (sc->sc_carpdev != NULL) {
                /* XXX linkstatehook removal */
@@ -880,6 +883,7 @@
        }
        sc->sc_carpdev = NULL;
        splx(s);
+       KERNEL_UNLOCK_ONE(NULL);
 }
 
 /* Detach an interface from the carp. */
@@ -946,6 +950,7 @@
        struct ifaddr *ifa;
        struct sockaddr sa;
 
+       KERNEL_LOCK(1, NULL);
        s = splsoftnet();
 
        advbase = advskew = 0; /* Sssssh compiler */
@@ -1148,6 +1153,7 @@
 
 retry_later:
        splx(s);
+       KERNEL_UNLOCK_ONE(NULL);
        if (advbase != 255 || advskew != 255)
                callout_schedule(&sc->sc_ad_tmo, tvtohz(&tv));
 }
@@ -1162,8 +1168,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)
@@ -1173,6 +1181,7 @@
                arprequest(sc->sc_carpdev, in, in, CLLADDR(sc->sc_if.if_sadl));
        }
        splx(s);
+       KERNEL_UNLOCK_ONE(NULL);
 }
 
 #ifdef INET6
@@ -1182,7 +1191,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) {
 
@@ -1194,6 +1206,7 @@
                    ND_NA_FLAG_OVERRIDE, 1, NULL);
        }
        splx(s);
+       KERNEL_UNLOCK_ONE(NULL);
 }
 #endif /* INET6 */
 
@@ -1598,10 +1611,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);
@@ -2060,6 +2075,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));
diff -r d13934b956d5 -r c7747724a09a sys/netinet6/ip6_flow.c
--- a/sys/netinet6/ip6_flow.c   Tue Jun 03 15:26:33 2014 +0000
+++ b/sys/netinet6/ip6_flow.c   Tue Jun 03 15:34:00 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip6_flow.c,v 1.19.2.2 2013/06/19 07:29:05 bouyer Exp $ */
+/*     $NetBSD: ip6_flow.c,v 1.19.2.3 2014/06/03 15:34:00 msaitoh Exp $        */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip6_flow.c,v 1.19.2.2 2013/06/19 07:29:05 bouyer Exp $");



Home | Main Index | Thread Index | Old Index