Source-Changes-HG archive

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

[src/trunk]: src/sys Fix LOCKDEBUG kernel panic when many(about ...



details:   https://anonhg.NetBSD.org/src/rev/f0cdb4a71acf
branches:  trunk
changeset: 318509:f0cdb4a71acf
user:      knakahara <knakahara%NetBSD.org@localhost>
date:      Fri Apr 27 09:55:27 2018 +0000
description:
Fix LOCKDEBUG kernel panic when many(about 200) tunnel interfaces is created.

The tunnel interfaces are gif(4), l2tp(4), and ipsecif(4). They use mutex
itself in percpu area. When percpu_cpu_enlarge() run, the address of the
mutex in percpu area becomes different from the address which lockdebug
saved. That can cause "already initialized" false detection.

diffstat:

 sys/net/if_gif.c        |   8 ++++----
 sys/net/if_gif.h        |   4 ++--
 sys/net/if_ipsec.c      |   8 ++++----
 sys/net/if_ipsec.h      |   4 ++--
 sys/net/if_l2tp.c       |   8 ++++----
 sys/net/if_l2tp.h       |   4 ++--
 sys/netinet/in_gif.c    |  12 ++++++------
 sys/netinet/in_l2tp.c   |  12 ++++++------
 sys/netinet6/in6_gif.c  |  12 ++++++------
 sys/netinet6/in6_l2tp.c |  12 ++++++------
 sys/netipsec/ipsecif.c  |  20 ++++++++++----------
 11 files changed, 52 insertions(+), 52 deletions(-)

diffs (truncated from 435 to 300 lines):

diff -r 70a2f20f22a4 -r f0cdb4a71acf sys/net/if_gif.c
--- a/sys/net/if_gif.c  Fri Apr 27 09:33:43 2018 +0000
+++ b/sys/net/if_gif.c  Fri Apr 27 09:55:27 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_gif.c,v 1.139 2018/02/12 15:38:14 maxv Exp $        */
+/*     $NetBSD: if_gif.c,v 1.140 2018/04/27 09:55:27 knakahara Exp $   */
 /*     $KAME: if_gif.c,v 1.76 2001/08/20 02:01:02 kjc Exp $    */
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.139 2018/02/12 15:38:14 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.140 2018/04/27 09:55:27 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -319,7 +319,7 @@
 {
        struct gif_ro *gro = p;
 
-       mutex_init(&gro->gr_lock, MUTEX_DEFAULT, IPL_NONE);
+       gro->gr_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NONE);
 }
 
 static void
@@ -329,7 +329,7 @@
 
        rtcache_free(&gro->gr_ro);
 
-       mutex_destroy(&gro->gr_lock);
+       mutex_obj_free(gro->gr_lock);
 }
 
 void
diff -r 70a2f20f22a4 -r f0cdb4a71acf sys/net/if_gif.h
--- a/sys/net/if_gif.h  Fri Apr 27 09:33:43 2018 +0000
+++ b/sys/net/if_gif.h  Fri Apr 27 09:55:27 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_gif.h,v 1.30 2018/04/19 21:20:43 christos Exp $     */
+/*     $NetBSD: if_gif.h,v 1.31 2018/04/27 09:55:27 knakahara Exp $    */
 /*     $KAME: if_gif.h,v 1.23 2001/07/27 09:21:42 itojun Exp $ */
 
 /*
@@ -56,7 +56,7 @@
 
 struct gif_ro {
        struct route gr_ro;
-       kmutex_t gr_lock;
+       kmutex_t *gr_lock;
 };
 
 struct gif_variant {
diff -r 70a2f20f22a4 -r f0cdb4a71acf sys/net/if_ipsec.c
--- a/sys/net/if_ipsec.c        Fri Apr 27 09:33:43 2018 +0000
+++ b/sys/net/if_ipsec.c        Fri Apr 27 09:55:27 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ipsec.c,v 1.12 2018/04/27 00:06:40 knakahara Exp $  */
+/*     $NetBSD: if_ipsec.c,v 1.13 2018/04/27 09:55:27 knakahara Exp $  */
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ipsec.c,v 1.12 2018/04/27 00:06:40 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ipsec.c,v 1.13 2018/04/27 09:55:27 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -220,7 +220,7 @@
 {
        struct ipsec_ro *iro = p;
 
-       mutex_init(&iro->ir_lock, MUTEX_DEFAULT, IPL_NONE);
+       iro->ir_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NONE);
 }
 
 static void
@@ -230,7 +230,7 @@
 
        rtcache_free(&iro->ir_ro);
 
-       mutex_destroy(&iro->ir_lock);
+       mutex_obj_free(iro->ir_lock);
 }
 
 static int
diff -r 70a2f20f22a4 -r f0cdb4a71acf sys/net/if_ipsec.h
--- a/sys/net/if_ipsec.h        Fri Apr 27 09:33:43 2018 +0000
+++ b/sys/net/if_ipsec.h        Fri Apr 27 09:55:27 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ipsec.h,v 1.2 2018/04/19 21:20:43 christos Exp $  */
+/*     $NetBSD: if_ipsec.h,v 1.3 2018/04/27 09:55:27 knakahara Exp $  */
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -87,7 +87,7 @@
 
 struct ipsec_ro {
        struct route ir_ro;
-       kmutex_t ir_lock;
+       kmutex_t *ir_lock;
 };
 
 struct ipsec_softc {
diff -r 70a2f20f22a4 -r f0cdb4a71acf sys/net/if_l2tp.c
--- a/sys/net/if_l2tp.c Fri Apr 27 09:33:43 2018 +0000
+++ b/sys/net/if_l2tp.c Fri Apr 27 09:55:27 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_l2tp.c,v 1.23 2018/04/10 11:44:13 knakahara Exp $   */
+/*     $NetBSD: if_l2tp.c,v 1.24 2018/04/27 09:55:27 knakahara Exp $   */
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_l2tp.c,v 1.23 2018/04/10 11:44:13 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_l2tp.c,v 1.24 2018/04/27 09:55:27 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -298,7 +298,7 @@
 {
        struct l2tp_ro *lro = p;
 
-       mutex_init(&lro->lr_lock, MUTEX_DEFAULT, IPL_NONE);
+       lro->lr_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NONE);
 }
 
 void
@@ -308,7 +308,7 @@
 
        rtcache_free(&lro->lr_ro);
 
-       mutex_destroy(&lro->lr_lock);
+       mutex_obj_free(lro->lr_lock);
 }
 
 static int
diff -r 70a2f20f22a4 -r f0cdb4a71acf sys/net/if_l2tp.h
--- a/sys/net/if_l2tp.h Fri Apr 27 09:33:43 2018 +0000
+++ b/sys/net/if_l2tp.h Fri Apr 27 09:55:27 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_l2tp.h,v 1.4 2018/04/19 21:20:43 christos Exp $     */
+/*     $NetBSD: if_l2tp.h,v 1.5 2018/04/27 09:55:27 knakahara Exp $    */
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -92,7 +92,7 @@
 
 struct l2tp_ro {
        struct route lr_ro;
-       kmutex_t lr_lock;
+       kmutex_t *lr_lock;
 };
 
 struct l2tp_softc {
diff -r 70a2f20f22a4 -r f0cdb4a71acf sys/netinet/in_gif.c
--- a/sys/netinet/in_gif.c      Fri Apr 27 09:33:43 2018 +0000
+++ b/sys/netinet/in_gif.c      Fri Apr 27 09:55:27 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in_gif.c,v 1.92 2018/01/10 11:13:26 knakahara Exp $    */
+/*     $NetBSD: in_gif.c,v 1.93 2018/04/27 09:55:28 knakahara Exp $    */
 /*     $KAME: in_gif.c,v 1.66 2001/07/29 04:46:09 itojun Exp $ */
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in_gif.c,v 1.92 2018/01/10 11:13:26 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in_gif.c,v 1.93 2018/04/27 09:55:28 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -176,10 +176,10 @@
 
        sc = var->gv_softc;
        gro = percpu_getref(sc->gif_ro_percpu);
-       mutex_enter(&gro->gr_lock);
+       mutex_enter(gro->gr_lock);
        ro = &gro->gr_ro;
        if ((rt = rtcache_lookup(ro, var->gv_pdst)) == NULL) {
-               mutex_exit(&gro->gr_lock);
+               mutex_exit(gro->gr_lock);
                percpu_putref(sc->gif_ro_percpu);
                m_freem(m);
                return ENETUNREACH;
@@ -189,7 +189,7 @@
        if (rt->rt_ifp == ifp) {
                rtcache_unref(rt, ro);
                rtcache_free(ro);
-               mutex_exit(&gro->gr_lock);
+               mutex_exit(gro->gr_lock);
                percpu_putref(sc->gif_ro_percpu);
                m_freem(m);
                return ENETUNREACH;     /*XXX*/
@@ -197,7 +197,7 @@
        rtcache_unref(rt, ro);
 
        error = ip_output(m, NULL, ro, 0, NULL, NULL);
-       mutex_exit(&gro->gr_lock);
+       mutex_exit(gro->gr_lock);
        percpu_putref(sc->gif_ro_percpu);
        return (error);
 }
diff -r 70a2f20f22a4 -r f0cdb4a71acf sys/netinet/in_l2tp.c
--- a/sys/netinet/in_l2tp.c     Fri Apr 27 09:33:43 2018 +0000
+++ b/sys/netinet/in_l2tp.c     Fri Apr 27 09:55:27 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in_l2tp.c,v 1.12 2018/01/26 07:49:15 maxv Exp $        */
+/*     $NetBSD: in_l2tp.c,v 1.13 2018/04/27 09:55:28 knakahara 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.12 2018/01/26 07:49:15 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in_l2tp.c,v 1.13 2018/04/27 09:55:28 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_l2tp.h"
@@ -209,9 +209,9 @@
        memcpy(mtod(m, struct ip *), &iphdr, sizeof(struct ip));
 
        lro = percpu_getref(sc->l2tp_ro_percpu);
-       mutex_enter(&lro->lr_lock);
+       mutex_enter(lro->lr_lock);
        if ((rt = rtcache_lookup(&lro->lr_ro, var->lv_pdst)) == NULL) {
-               mutex_exit(&lro->lr_lock);
+               mutex_exit(lro->lr_lock);
                percpu_putref(sc->l2tp_ro_percpu);
                m_freem(m);
                error = ENETUNREACH;
@@ -221,7 +221,7 @@
        if (rt->rt_ifp == ifp) {
                rtcache_unref(rt, &lro->lr_ro);
                rtcache_free(&lro->lr_ro);
-               mutex_exit(&lro->lr_lock);
+               mutex_exit(lro->lr_lock);
                percpu_putref(sc->l2tp_ro_percpu);
                m_freem(m);
                error = ENETUNREACH;    /*XXX*/
@@ -236,7 +236,7 @@
        m->m_pkthdr.csum_flags  = 0;
 
        error = ip_output(m, NULL, &lro->lr_ro, 0, NULL, NULL);
-       mutex_exit(&lro->lr_lock);
+       mutex_exit(lro->lr_lock);
        percpu_putref(sc->l2tp_ro_percpu);
        return error;
 
diff -r 70a2f20f22a4 -r f0cdb4a71acf sys/netinet6/in6_gif.c
--- a/sys/netinet6/in6_gif.c    Fri Apr 27 09:33:43 2018 +0000
+++ b/sys/netinet6/in6_gif.c    Fri Apr 27 09:55:27 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in6_gif.c,v 1.91 2018/03/14 07:56:32 knakahara Exp $   */
+/*     $NetBSD: in6_gif.c,v 1.92 2018/04/27 09:55:28 knakahara Exp $   */
 /*     $KAME: in6_gif.c,v 1.62 2001/07/29 04:27:25 itojun Exp $        */
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6_gif.c,v 1.91 2018/03/14 07:56:32 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_gif.c,v 1.92 2018/04/27 09:55:28 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -182,11 +182,11 @@
 
        sc = ifp->if_softc;
        gro = percpu_getref(sc->gif_ro_percpu);
-       mutex_enter(&gro->gr_lock);
+       mutex_enter(gro->gr_lock);
        ro = &gro->gr_ro;
        rt = rtcache_lookup(ro, var->gv_pdst);
        if (rt == NULL) {
-               mutex_exit(&gro->gr_lock);
+               mutex_exit(gro->gr_lock);
                percpu_putref(sc->gif_ro_percpu);
                m_freem(m);
                return ENETUNREACH;
@@ -196,7 +196,7 @@
        if (rt->rt_ifp == ifp) {
                rtcache_unref(rt, ro);
                rtcache_free(ro);
-               mutex_exit(&gro->gr_lock);
+               mutex_exit(gro->gr_lock);
                percpu_putref(sc->gif_ro_percpu);
                m_freem(m);
                return ENETUNREACH;     /* XXX */



Home | Main Index | Thread Index | Old Index