Module Name:    src
Committed By:   christos
Date:           Fri Apr  3 14:04:27 UTC 2020

Modified Files:
        src/sys/netinet6: nd6.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.267 -r1.268 src/sys/netinet6/nd6.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netinet6/nd6.c
diff -u src/sys/netinet6/nd6.c:1.267 src/sys/netinet6/nd6.c:1.268
--- src/sys/netinet6/nd6.c:1.267	Mon Mar  9 17:20:56 2020
+++ src/sys/netinet6/nd6.c	Fri Apr  3 10:04:27 2020
@@ -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 @@ nd6_llinfo_timer(void *arg)
 	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 @@ nd6_llinfo_timer(void *arg)
 		}
 
 		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 @@ nd6_llinfo_timer(void *arg)
 			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 @@ out:
 	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);
+	}
 }
 
 /*

Reply via email to