Source-Changes-HG archive

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

[src/netbsd-8]: src/sys Pull up following revision(s) via patch (requested by...



details:   https://anonhg.NetBSD.org/src/rev/ec25fb92c8e1
branches:  netbsd-8
changeset: 320599:ec25fb92c8e1
user:      martin <martin%NetBSD.org@localhost>
date:      Fri Jul 13 14:26:47 2018 +0000

description:
Pull up following revision(s) via patch (requested by knakahara in ticket #905):

        sys/netinet/ip_mroute.c: revision 1.160
        sys/netinet6/in6_l2tp.c: revision 1.16
        sys/net/if.h: revision 1.263
        sys/netinet/in_l2tp.c: revision 1.15
        sys/netinet/ip_icmp.c: revision 1.172
        sys/netinet/igmp.c: revision 1.68
        sys/netinet/ip_encap.c: revision 1.69
        sys/netinet6/ip6_mroute.c: revision 1.129

sbappendaddr() is required any lock. Currently, softnet_lock is appropriate.

When rip_input() is called as inetsw[].pr_input, rip_iput() is always called
with holding softnet_lock, that is, in case of !defined(NET_MPSAFE) it is
acquired in ipintr(), otherwise(defined(NET_MPSAFE)) it is acquire in
PR_WRAP_INPUT macro.

However, some function calls rip_input() directly without holding softnet_lock.
That causes assertion failure in sbappendaddr().
rip6_input() and icmp6_rip6_input() are also required softnet_lock for the same
reason.

diffstat:

 sys/net/if.h              |  10 +++++++++-
 sys/netinet/igmp.c        |   9 +++++++--
 sys/netinet/in_l2tp.c     |   7 +++++--
 sys/netinet/ip_encap.c    |  12 +++++++++---
 sys/netinet/ip_icmp.c     |   9 +++++++--
 sys/netinet/ip_mroute.c   |  10 ++++++++--
 sys/netinet6/in6_l2tp.c   |  10 +++++++---
 sys/netinet6/ip6_mroute.c |   9 +++++++--
 8 files changed, 59 insertions(+), 17 deletions(-)

diffs (278 lines):

diff -r a1e167271c94 -r ec25fb92c8e1 sys/net/if.h
--- a/sys/net/if.h      Thu Jul 12 15:26:11 2018 +0000
+++ b/sys/net/if.h      Fri Jul 13 14:26:47 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.h,v 1.239.2.5 2018/04/14 10:16:19 martin Exp $      */
+/*     $NetBSD: if.h,v 1.239.2.6 2018/07/13 14:26:48 martin Exp $      */
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -534,6 +534,11 @@
 #define SOFTNET_LOCK_UNLESS_NET_MPSAFE()       do { } while (0)
 #define SOFTNET_UNLOCK_UNLESS_NET_MPSAFE()     do { } while (0)
 
+#define SOFTNET_LOCK_IF_NET_MPSAFE()                                   \
+       do { mutex_enter(softnet_lock); } while (0)
+#define SOFTNET_UNLOCK_IF_NET_MPSAFE()                                 \
+       do { mutex_exit(softnet_lock); } while (0)
+
 #else /* NET_MPSAFE */
 
 #define KERNEL_LOCK_UNLESS_NET_MPSAFE()                                        \
@@ -546,6 +551,9 @@
 #define SOFTNET_UNLOCK_UNLESS_NET_MPSAFE()                             \
        do { mutex_exit(softnet_lock); } while (0)
 
+#define SOFTNET_LOCK_IF_NET_MPSAFE()           do { } while (0)
+#define SOFTNET_UNLOCK_IF_NET_MPSAFE()         do { } while (0)
+
 #endif /* NET_MPSAFE */
 
 #define SOFTNET_KERNEL_LOCK_UNLESS_NET_MPSAFE()                                \
diff -r a1e167271c94 -r ec25fb92c8e1 sys/netinet/igmp.c
--- a/sys/netinet/igmp.c        Thu Jul 12 15:26:11 2018 +0000
+++ b/sys/netinet/igmp.c        Fri Jul 13 14:26:47 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: igmp.c,v 1.64.6.1 2018/01/02 10:20:34 snj Exp $        */
+/*     $NetBSD: igmp.c,v 1.64.6.2 2018/07/13 14:26:47 martin Exp $     */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: igmp.c,v 1.64.6.1 2018/01/02 10:20:34 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: igmp.c,v 1.64.6.2 2018/07/13 14:26:47 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mrouting.h"
@@ -474,6 +474,11 @@
         * Pass all valid IGMP packets up to any process(es) listening
         * on a raw IGMP socket.
         */
+       /*
+        * Currently, igmp_input() is always called holding softnet_lock
+        * by ipintr()(!NET_MPSAFE) or PR_INPUT_WRAP()(NET_MPSAFE).
+        */
+       KASSERT(mutex_owned(softnet_lock));
        rip_input(m, iphlen, proto);
        return;
 
diff -r a1e167271c94 -r ec25fb92c8e1 sys/netinet/in_l2tp.c
--- a/sys/netinet/in_l2tp.c     Thu Jul 12 15:26:11 2018 +0000
+++ b/sys/netinet/in_l2tp.c     Fri Jul 13 14:26:47 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in_l2tp.c,v 1.2.8.5 2018/05/17 14:07:03 martin Exp $   */
+/*     $NetBSD: in_l2tp.c,v 1.2.8.6 2018/07/13 14:26:47 martin Exp $   */
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in_l2tp.c,v 1.2.8.5 2018/05/17 14:07:03 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in_l2tp.c,v 1.2.8.6 2018/07/13 14:26:47 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_l2tp.h"
@@ -42,6 +42,7 @@
 #include <sys/ioctl.h>
 #include <sys/syslog.h>
 #include <sys/kernel.h>
+#include <sys/socketvar.h> /* For softnet_lock */
 
 #include <net/if.h>
 #include <net/route.h>
@@ -277,7 +278,9 @@
                 * L2TPv3 control packet received.
                 * userland daemon(l2tpd?) should process.
                 */
+               SOFTNET_LOCK_IF_NET_MPSAFE();
                rip_input(m, off, proto);
+               SOFTNET_UNLOCK_IF_NET_MPSAFE();
                return;
        }
 
diff -r a1e167271c94 -r ec25fb92c8e1 sys/netinet/ip_encap.c
--- a/sys/netinet/ip_encap.c    Thu Jul 12 15:26:11 2018 +0000
+++ b/sys/netinet/ip_encap.c    Fri Jul 13 14:26:47 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_encap.c,v 1.65.2.2 2018/03/30 11:12:15 martin Exp $ */
+/*     $NetBSD: ip_encap.c,v 1.65.2.3 2018/07/13 14:26:47 martin Exp $ */
 /*     $KAME: ip_encap.c,v 1.73 2001/10/02 08:30:58 itojun Exp $       */
 
 /*
@@ -68,7 +68,7 @@
 #define USE_RADIX
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_encap.c,v 1.65.2.2 2018/03/30 11:12:15 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_encap.c,v 1.65.2.3 2018/07/13 14:26:47 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mrouting.h"
@@ -374,7 +374,9 @@
        }
 
        /* last resort: inject to raw socket */
+       SOFTNET_LOCK_IF_NET_MPSAFE();
        rip_input(m, off, proto);
+       SOFTNET_UNLOCK_IF_NET_MPSAFE();
 }
 #endif
 
@@ -496,6 +498,7 @@
        const struct encapsw *esw;
        struct encaptab *match;
        struct psref match_psref;
+       int rv;
 
        match = encap6_lookup(m, *offp, proto, INBOUND, &match_psref);
 
@@ -518,7 +521,10 @@
        }
 
        /* last resort: inject to raw socket */
-       return rip6_input(mp, offp, proto);
+       SOFTNET_LOCK_IF_NET_MPSAFE();
+       rv = rip6_input(mp, offp, proto);
+       SOFTNET_UNLOCK_IF_NET_MPSAFE();
+       return rv;
 }
 #endif
 
diff -r a1e167271c94 -r ec25fb92c8e1 sys/netinet/ip_icmp.c
--- a/sys/netinet/ip_icmp.c     Thu Jul 12 15:26:11 2018 +0000
+++ b/sys/netinet/ip_icmp.c     Fri Jul 13 14:26:47 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_icmp.c,v 1.161.6.2 2018/06/08 10:14:33 martin Exp $ */
+/*     $NetBSD: ip_icmp.c,v 1.161.6.3 2018/07/13 14:26:47 martin Exp $ */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -94,7 +94,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.161.6.2 2018/06/08 10:14:33 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.161.6.3 2018/07/13 14:26:47 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ipsec.h"
@@ -709,6 +709,11 @@
        }
 
 raw:
+       /*
+        * Currently, pim_input() is always called holding softnet_lock
+        * by ipintr()(!NET_MPSAFE) or PR_INPUT_WRAP()(NET_MPSAFE).
+        */
+       KASSERT(mutex_owned(softnet_lock));
        rip_input(m, hlen, proto);
        return;
 
diff -r a1e167271c94 -r ec25fb92c8e1 sys/netinet/ip_mroute.c
--- a/sys/netinet/ip_mroute.c   Thu Jul 12 15:26:11 2018 +0000
+++ b/sys/netinet/ip_mroute.c   Fri Jul 13 14:26:47 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_mroute.c,v 1.146.6.3 2018/04/09 13:34:10 bouyer Exp $       */
+/*     $NetBSD: ip_mroute.c,v 1.146.6.4 2018/07/13 14:26:47 martin Exp $       */
 
 /*
  * Copyright (c) 1992, 1993
@@ -93,7 +93,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_mroute.c,v 1.146.6.3 2018/04/09 13:34:10 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_mroute.c,v 1.146.6.4 2018/07/13 14:26:47 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2363,6 +2363,7 @@
        if (ip_rsvpd != NULL) {
                RSVP_DPRINTF(("%s: Sending packet up old-style socket\n",
                    __func__));
+               /* rsvp_input() is not called, not care */
                rip_input(m);   /*XXX*/
                return;
        }
@@ -3463,6 +3464,11 @@
      * XXX: the outer IP header pkt size of a Register is not adjust to
      * reflect the fact that the inner multicast data is truncated.
      */
+    /*
+     * Currently, pim_input() is always called holding softnet_lock
+     * by ipintr()(!NET_MPSAFE) or PR_INPUT_WRAP()(NET_MPSAFE).
+     */
+    KASSERT(mutex_owned(softnet_lock));
     rip_input(m, iphlen, proto);
 
     return;
diff -r a1e167271c94 -r ec25fb92c8e1 sys/netinet6/in6_l2tp.c
--- a/sys/netinet6/in6_l2tp.c   Thu Jul 12 15:26:11 2018 +0000
+++ b/sys/netinet6/in6_l2tp.c   Fri Jul 13 14:26:47 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in6_l2tp.c,v 1.5.8.5 2018/05/17 14:07:03 martin Exp $  */
+/*     $NetBSD: in6_l2tp.c,v 1.5.8.6 2018/07/13 14:26:47 martin Exp $  */
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6_l2tp.c,v 1.5.8.5 2018/05/17 14:07:03 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_l2tp.c,v 1.5.8.6 2018/07/13 14:26:47 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_l2tp.h"
@@ -267,11 +267,15 @@
        log(LOG_DEBUG, "%s: sess_id = %" PRIu32 "\n", __func__, sess_id);
 #endif
        if (sess_id == 0) {
+               int rv;
                /*
                 * L2TPv3 control packet received.
                 * userland daemon(l2tpd?) should process.
                 */
-               return rip6_input(mp, offp, proto);
+               SOFTNET_LOCK_IF_NET_MPSAFE();
+               rv = rip6_input(mp, offp, proto);
+               SOFTNET_UNLOCK_IF_NET_MPSAFE();
+               return rv;
        }
 
        var = l2tp_lookup_session_ref(sess_id, &psref);
diff -r a1e167271c94 -r ec25fb92c8e1 sys/netinet6/ip6_mroute.c
--- a/sys/netinet6/ip6_mroute.c Thu Jul 12 15:26:11 2018 +0000
+++ b/sys/netinet6/ip6_mroute.c Fri Jul 13 14:26:47 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip6_mroute.c,v 1.119.6.2 2018/04/09 13:34:10 bouyer Exp $      */
+/*     $NetBSD: ip6_mroute.c,v 1.119.6.3 2018/07/13 14:26:47 martin Exp $      */
 /*     $KAME: ip6_mroute.c,v 1.49 2001/07/25 09:21:18 jinmei Exp $     */
 
 /*
@@ -117,7 +117,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip6_mroute.c,v 1.119.6.2 2018/04/09 13:34:10 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_mroute.c,v 1.119.6.3 2018/07/13 14:26:47 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1951,6 +1951,11 @@
         * encapsulated ip6 header.
         */
   pim6_input_to_daemon:
+       /*
+        * Currently, rip6_input() is always called holding softnet_lock
+        * by ipintr()(!NET_MPSAFE) or PR_INPUT_WRAP()(NET_MPSAFE).
+        */
+       KASSERT(mutex_owned(softnet_lock));
        rip6_input(&m, offp, proto);
        return (IPPROTO_DONE);
 }



Home | Main Index | Thread Index | Old Index