Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 30 Oct 2010 11:30:50 +0000 (UTC)
From:      "Bjoern A. Zeeb" <bz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
Subject:   svn commit: r214551 - stable/7/sys/net
Message-ID:  <201010301130.o9UBUogA095443@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bz
Date: Sat Oct 30 11:30:49 2010
New Revision: 214551
URL: http://svn.freebsd.org/changeset/base/214551

Log:
  MFC r213930:
  
    Close a race acquiring the IF_ADDR_LOCK() for each entry while iterating
    over all interfaces to make sure the address will neither change nor be
    freed while we are working on it.
  
    PR:		kern/146250
    Submitted by:	Mikolaj Golub (to.my.trociny gmail.com)

Modified:
  stable/7/sys/net/rtsock.c
Directory Properties:
  stable/7/sys/   (props changed)
  stable/7/sys/cddl/contrib/opensolaris/   (props changed)
  stable/7/sys/contrib/dev/acpica/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)

Modified: stable/7/sys/net/rtsock.c
==============================================================================
--- stable/7/sys/net/rtsock.c	Sat Oct 30 10:38:23 2010	(r214550)
+++ stable/7/sys/net/rtsock.c	Sat Oct 30 11:30:49 2010	(r214551)
@@ -1261,6 +1261,7 @@ sysctl_iflist(int af, struct walkarg *w)
 	TAILQ_FOREACH(ifp, &ifnet, if_link) {
 		if (w->w_arg && w->w_arg != ifp->if_index)
 			continue;
+		IF_ADDR_LOCK(ifp);
 		ifa = ifp->if_addr;
 		info.rti_info[RTAX_IFP] = ifa->ifa_addr;
 		len = rt_msg2(RTM_IFINFO, &info, NULL, w);
@@ -1300,10 +1301,13 @@ sysctl_iflist(int af, struct walkarg *w)
 					goto done;
 			}
 		}
+		IF_ADDR_UNLOCK(ifp);
 		info.rti_info[RTAX_IFA] = info.rti_info[RTAX_NETMASK] =
 			info.rti_info[RTAX_BRD] = NULL;
 	}
 done:
+	if (ifp != NULL)
+		IF_ADDR_UNLOCK(ifp);
 	IFNET_RUNLOCK();
 	return (error);
 }



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