Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Oct 2019 14:51:38 +0000 (UTC)
From:      Michael Tuexen <tuexen@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r353400 - stable/12/sys/netinet
Message-ID:  <201910101451.x9AEpcOK068837@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: tuexen
Date: Thu Oct 10 14:51:38 2019
New Revision: 353400
URL: https://svnweb.freebsd.org/changeset/base/353400

Log:
  MFC r353123:
  
  Fix a use after free bug when removing remote addresses.
  This bug was found by OSS-Fuzz and reported in
  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18004

Modified:
  stable/12/sys/netinet/sctp_asconf.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/netinet/sctp_asconf.c
==============================================================================
--- stable/12/sys/netinet/sctp_asconf.c	Thu Oct 10 14:50:44 2019	(r353399)
+++ stable/12/sys/netinet/sctp_asconf.c	Thu Oct 10 14:51:38 2019	(r353400)
@@ -283,7 +283,7 @@ sctp_process_asconf_add_ip(struct sockaddr *src, struc
 static int
 sctp_asconf_del_remote_addrs_except(struct sctp_tcb *stcb, struct sockaddr *src)
 {
-	struct sctp_nets *src_net, *net;
+	struct sctp_nets *src_net, *net, *nnet;
 
 	/* make sure the source address exists as a destination net */
 	src_net = sctp_findnet(stcb, src);
@@ -293,10 +293,9 @@ sctp_asconf_del_remote_addrs_except(struct sctp_tcb *s
 	}
 
 	/* delete all destination addresses except the source */
-	TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
+	TAILQ_FOREACH_SAFE(net, &stcb->asoc.nets, sctp_next, nnet) {
 		if (net != src_net) {
 			/* delete this address */
-			sctp_remove_net(stcb, net);
 			SCTPDBG(SCTP_DEBUG_ASCONF1,
 			    "asconf_del_remote_addrs_except: deleting ");
 			SCTPDBG_ADDR(SCTP_DEBUG_ASCONF1,
@@ -304,6 +303,7 @@ sctp_asconf_del_remote_addrs_except(struct sctp_tcb *s
 			/* notify upper layer */
 			sctp_ulp_notify(SCTP_NOTIFY_ASCONF_DELETE_IP, stcb, 0,
 			    (struct sockaddr *)&net->ro._l_addr, SCTP_SO_NOT_LOCKED);
+			sctp_remove_net(stcb, net);
 		}
 	}
 	return (0);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201910101451.x9AEpcOK068837>