Source-Changes-HG archive

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

[src/trunk]: src/sys/netinet6 PR/55030: Avoid locking against myself panic by...



details:   https://anonhg.NetBSD.org/src/rev/30ef961c803d
branches:  trunk
changeset: 1008784:30ef961c803d
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Apr 03 14:04:27 2020 +0000

description:
PR/55030: Avoid locking against myself panic by moving the icmp error outside
the lock. Thanks ozaki-r!

diffstat:

 sys/netinet6/nd6.c |  16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diffs (58 lines):

diff -r f72585596dbb -r 30ef961c803d sys/netinet6/nd6.c
--- a/sys/netinet6/nd6.c        Fri Apr 03 13:57:48 2020 +0000
+++ b/sys/netinet6/nd6.c        Fri Apr 03 14:04:27 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nd6.c,v 1.267 2020/03/09 21:20:56 roy Exp $    */
+/*     $NetBSD: nd6.c,v 1.268 2020/04/03 14:04:27 christos Exp $       */
 /*     $KAME: nd6.c,v 1.279 2002/06/08 11:16:51 itojun Exp $   */
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.267 2020/03/09 21:20:56 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.268 2020/04/03 14:04:27 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -463,6 +463,7 @@
        const struct in6_addr *taddr6 = &ln->r_l3addr.addr6;
        struct sockaddr_in6 dsin6, tsin6;
        struct sockaddr *sa;
+       struct mbuf *m = NULL;
 
        SOFTNET_KERNEL_LOCK_UNLESS_NET_MPSAFE();
 
@@ -493,7 +494,9 @@
                }
 
                if (ln->ln_hold) {
-                       struct mbuf *m = ln->ln_hold, *m0;
+                       struct mbuf *m0;
+
+                       m = ln->ln_hold;
 
                        /*
                         * assuming every packet in ln_hold has
@@ -503,9 +506,6 @@
                        m->m_nextpkt = NULL;
                        ln->ln_hold = m0;
                        clear_llinfo_pqueue(ln);
-
-                       icmp6_error2(m, ICMP6_DST_UNREACH,
-                           ICMP6_DST_UNREACH_ADDR, 0, ifp, &mdaddr6);
                }
 
                sockaddr_in6_init(&tsin6, taddr6, 0, 0, 0);
@@ -586,6 +586,10 @@
        if (ln != NULL)
                LLE_FREE_LOCKED(ln);
        SOFTNET_KERNEL_UNLOCK_UNLESS_NET_MPSAFE();
+       if (m) {
+               icmp6_error2(m, ICMP6_DST_UNREACH,
+                   ICMP6_DST_UNREACH_ADDR, 0, ifp, &mdaddr6);
+       }
 }
 
 /*



Home | Main Index | Thread Index | Old Index