Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/bfc29084700a
branches:  netbsd-6-1
changeset: 775955:bfc29084700a
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Wed Jun 18 09:34:26 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 f07b8a1d9241 -r bfc29084700a sys/dist/ipf/netinet/ip_fil_netbsd.c
--- a/sys/dist/ipf/netinet/ip_fil_netbsd.c      Wed Jun 18 02:15:51 2014 +0000
+++ b/sys/dist/ipf/netinet/ip_fil_netbsd.c      Wed Jun 18 09:34:26 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.1.2.1 2014/06/18 09:34:26 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.1.2.1 2014/06/18 09:34:26 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 f07b8a1d9241 -r bfc29084700a sys/net/if_ethersubr.c
--- a/sys/net/if_ethersubr.c    Wed Jun 18 02:15:51 2014 +0000
+++ b/sys/net/if_ethersubr.c    Wed Jun 18 09:34:26 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.3.2.1 2014/06/18 09:34:27 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.3.2.1 2014/06/18 09:34:27 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 f07b8a1d9241 -r bfc29084700a sys/net/if_loop.c
--- a/sys/net/if_loop.c Wed Jun 18 02:15:51 2014 +0000
+++ b/sys/net/if_loop.c Wed Jun 18 09:34:26 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.18.1 2014/06/18 09:34:27 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.18.1 2014/06/18 09:34:27 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 f07b8a1d9241 -r bfc29084700a sys/net/if_vlan.c
--- a/sys/net/if_vlan.c Wed Jun 18 02:15:51 2014 +0000
+++ b/sys/net/if_vlan.c Wed Jun 18 09:34:26 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.22.1 2014/06/18 09:34:27 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.22.1 2014/06/18 09:34:27 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 f07b8a1d9241 -r bfc29084700a sys/netinet/if_arp.c
--- a/sys/netinet/if_arp.c      Wed Jun 18 02:15:51 2014 +0000
+++ b/sys/netinet/if_arp.c      Wed Jun 18 09:34:26 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.16.1 2014/06/18 09:34:27 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.16.1 2014/06/18 09:34:27 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 f07b8a1d9241 -r bfc29084700a sys/netinet/ip_carp.c
--- a/sys/netinet/ip_carp.c     Wed Jun 18 02:15:51 2014 +0000
+++ b/sys/netinet/ip_carp.c     Wed Jun 18 09:34:26 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_carp.c,v 1.47.4.1 2012/04/02 18:25:35 riz Exp $     */
+/*     $NetBSD: ip_carp.c,v 1.47.4.1.6.1 2014/06/18 09:34:27 msaitoh Exp $     */
 /*     $OpenBSD: ip_carp.c,v 1.113 2005/11/04 08:11:54 mcbride Exp $   */
 
 /*
@@ -30,7 +30,7 @@
 #include "opt_inet.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.47.4.1 2012/04/02 18:25:35 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.47.4.1.6.1 2014/06/18 09:34:27 msaitoh Exp $");
 
 /*
  * TODO:
@@ -347,6 +347,7 @@
        struct ifaddr *ifa;
        int s;
 
+       KERNEL_LOCK(1, NULL);
        s = splsoftnet();
        IFADDR_FOREACH(ifa, &sc->sc_if) {
                switch (ifa->ifa_addr->sa_family) {
@@ -444,6 +445,7 @@
                }
        }
        splx(s);
+       KERNEL_UNLOCK_ONE(NULL);
 }
 
 /*
@@ -844,6 +846,7 @@
        carp_setrun(sc, 0);
        carp_multicast_cleanup(sc);
 
+       KERNEL_LOCK(1, NULL);
        s = splnet();
        if (sc->sc_carpdev != NULL) {
                /* XXX linkstatehook removal */
@@ -857,6 +860,7 @@
        }
        sc->sc_carpdev = NULL;
        splx(s);
+       KERNEL_UNLOCK_ONE(NULL);
 }
 
 /* Detach an interface from the carp. */
@@ -923,6 +927,7 @@
        struct ifaddr *ifa;
        struct sockaddr sa;
 
+       KERNEL_LOCK(1, NULL);
        s = splsoftnet();
 
        advbase = advskew = 0; /* Sssssh compiler */
@@ -1123,6 +1128,7 @@
 
 retry_later:
        splx(s);
+       KERNEL_UNLOCK_ONE(NULL);
        if (advbase != 255 || advskew != 255)
                callout_schedule(&sc->sc_ad_tmo, tvtohz(&tv));
 }
@@ -1137,8 +1143,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)
@@ -1148,6 +1156,7 @@
                arprequest(sc->sc_carpdev, in, in, CLLADDR(sc->sc_if.if_sadl));
        }
        splx(s);
+       KERNEL_UNLOCK_ONE(NULL);
 }
 
 #ifdef INET6
@@ -1157,7 +1166,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) {
 
@@ -1169,6 +1181,7 @@
                    ND_NA_FLAG_OVERRIDE, 1, NULL);
        }
        splx(s);
+       KERNEL_UNLOCK_ONE(NULL);
 }
 #endif /* INET6 */
 
@@ -1573,10 +1586,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);
@@ -2035,6 +2050,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 f07b8a1d9241 -r bfc29084700a sys/netinet6/ip6_flow.c
--- a/sys/netinet6/ip6_flow.c   Wed Jun 18 02:15:51 2014 +0000
+++ b/sys/netinet6/ip6_flow.c   Wed Jun 18 09:34:26 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip6_flow.c,v 1.19.2.1 2012/10/31 16:07:46 riz Exp $    */
+/*     $NetBSD: ip6_flow.c,v 1.19.2.1.2.1 2014/06/18 09:34:27 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.1 2012/10/31 16:07:46 riz Exp $");



Home | Main Index | Thread Index | Old Index