Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Aug 2019 12:42:04 +0000 (UTC)
From:      "Andrey V. Elsukov" <ae@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r351214 - head/sys/kern
Message-ID:  <201908191242.x7JCg4Gu005302@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ae
Date: Mon Aug 19 12:42:03 2019
New Revision: 351214
URL: https://svnweb.freebsd.org/changeset/base/351214

Log:
  Use TAILQ_FOREACH_SAFE() macro to avoid use after free in soclose().
  
  PR:		239893
  MFC after:	1 week

Modified:
  head/sys/kern/uipc_socket.c

Modified: head/sys/kern/uipc_socket.c
==============================================================================
--- head/sys/kern/uipc_socket.c	Mon Aug 19 11:18:36 2019	(r351213)
+++ head/sys/kern/uipc_socket.c	Mon Aug 19 12:42:03 2019	(r351214)
@@ -1131,9 +1131,9 @@ drop:
 	so->so_state |= SS_NOFDREF;
 	sorele(so);
 	if (listening) {
-		struct socket *sp;
+		struct socket *sp, *tsp;
 
-		TAILQ_FOREACH(sp, &lqueue, so_list) {
+		TAILQ_FOREACH_SAFE(sp, &lqueue, so_list, tsp) {
 			SOCK_LOCK(sp);
 			if (sp->so_count == 0) {
 				SOCK_UNLOCK(sp);



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