Module Name:    src
Committed By:   knakahara
Date:           Mon Oct 25 02:06:29 UTC 2021

Modified Files:
        src/sys/net: if_spppsubr.c

Log Message:
Fix missing curlwp_bind() for ifa_release(), ok'ed by yamaguchi@n.o.

This causes the following KASSERT failure in pppoe server.
    - sppp_rcr_event()
      - sppp_ipcp_confreq()
        - sppp_get_ip_addrs()
          - psref_release()

After if_spppsubr.c:1.227, sppp_ipcp_confreq() is done in workqueue
instead of softint.


To generate a diff of this commit:
cvs rdiff -u -r1.259 -r1.260 src/sys/net/if_spppsubr.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/net/if_spppsubr.c
diff -u src/sys/net/if_spppsubr.c:1.259 src/sys/net/if_spppsubr.c:1.260
--- src/sys/net/if_spppsubr.c:1.259	Mon Oct 11 05:13:11 2021
+++ src/sys/net/if_spppsubr.c	Mon Oct 25 02:06:29 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_spppsubr.c,v 1.259 2021/10/11 05:13:11 knakahara Exp $	 */
+/*	$NetBSD: if_spppsubr.c,v 1.260 2021/10/25 02:06:29 knakahara Exp $	 */
 
 /*
  * Synchronous PPP/Cisco link level subroutines.
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.259 2021/10/11 05:13:11 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.260 2021/10/25 02:06:29 knakahara Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -5591,7 +5591,7 @@ sppp_get_ip_addrs(struct sppp *sp, uint3
 	struct ifaddr *ifa;
 	struct sockaddr_in *si, *sm;
 	uint32_t ssrc, ddst;
-	int s;
+	int bound, s;
 	struct psref psref;
 
 	sm = NULL;
@@ -5601,6 +5601,7 @@ sppp_get_ip_addrs(struct sppp *sp, uint3
 	 * aliases don't make any sense on a p2p link anyway.
 	 */
 	si = 0;
+	bound = curlwp_bind();
 	s = pserialize_read_enter();
 	IFADDR_READER_FOREACH(ifa, ifp) {
 		if (ifa->ifa_addr->sa_family == AF_INET) {
@@ -5625,6 +5626,7 @@ sppp_get_ip_addrs(struct sppp *sp, uint3
 			ddst = si->sin_addr.s_addr;
 		ifa_release(ifa, &psref);
 	}
+	curlwp_bindx(bound);
 
 	if (dst) *dst = ntohl(ddst);
 	if (src) *src = ntohl(ssrc);
@@ -5783,7 +5785,7 @@ sppp_get_ip6_addrs(struct sppp *sp, stru
 	struct ifaddr *ifa;
 	struct sockaddr_in6 *si, *sm;
 	struct in6_addr ssrc, ddst;
-	int s;
+	int bound, s;
 	struct psref psref;
 
 	sm = NULL;
@@ -5794,6 +5796,7 @@ sppp_get_ip6_addrs(struct sppp *sp, stru
 	 * aliases don't make any sense on a p2p link anyway.
 	 */
 	si = 0;
+	bound = curlwp_bind();
 	s = pserialize_read_enter();
 	IFADDR_READER_FOREACH(ifa, ifp) {
 		if (ifa->ifa_addr->sa_family == AF_INET6) {
@@ -5821,6 +5824,7 @@ sppp_get_ip6_addrs(struct sppp *sp, stru
 			memcpy(&ddst, &si->sin6_addr, sizeof(ddst));
 		ifa_release(ifa, &psref);
 	}
+	curlwp_bindx(bound);
 
 	if (dst)
 		memcpy(dst, &ddst, sizeof(*dst));

Reply via email to