Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 31 Dec 2011 01:08:31 +0000 (UTC)
From:      Pyun YongHyeon <yongari@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r229058 - in stable/8/sys: conf dev/age dev/alc dev/ale dev/lge dev/msk dev/nfe dev/nge dev/nve dev/re dev/sge dev/sis dev/vge dev/vr dev/vte mips/atheros mips/idt pci
Message-ID:  <201112310108.pBV18VB2039584@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: yongari
Date: Sat Dec 31 01:08:31 2011
New Revision: 229058
URL: http://svn.freebsd.org/changeset/base/229058

Log:
  MFC r226478:
    Close a race where SIOCGIFMEDIA ioctl get inconsistent link status.
    Because driver is accessing a common MII structure in
    mii_pollstat(), updating user supplied structure should be done
    before dropping a driver lock.
  
    Reported by:	Karim (fodillemlinkarimi <> gmail dot com)

Modified:
  stable/8/sys/dev/age/if_age.c
  stable/8/sys/dev/alc/if_alc.c
  stable/8/sys/dev/ale/if_ale.c
  stable/8/sys/dev/lge/if_lge.c
  stable/8/sys/dev/msk/if_msk.c
  stable/8/sys/dev/nfe/if_nfe.c
  stable/8/sys/dev/nge/if_nge.c
  stable/8/sys/dev/nve/if_nve.c
  stable/8/sys/dev/re/if_re.c
  stable/8/sys/dev/sge/if_sge.c
  stable/8/sys/dev/sis/if_sis.c
  stable/8/sys/dev/vge/if_vge.c
  stable/8/sys/dev/vr/if_vr.c
  stable/8/sys/dev/vte/if_vte.c
  stable/8/sys/mips/atheros/if_arge.c
  stable/8/sys/mips/idt/if_kr.c
  stable/8/sys/pci/if_rl.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/conf/ldscript.mips.octeon1.32   (props changed)
  stable/8/sys/conf/ldscript.mips.octeon1.64   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/dev/age/if_age.c
==============================================================================
--- stable/8/sys/dev/age/if_age.c	Sat Dec 31 01:07:01 2011	(r229057)
+++ stable/8/sys/dev/age/if_age.c	Sat Dec 31 01:08:31 2011	(r229058)
@@ -282,9 +282,9 @@ age_mediastatus(struct ifnet *ifp, struc
 	mii = device_get_softc(sc->age_miibus);
 
 	mii_pollstat(mii);
-	AGE_UNLOCK(sc);
 	ifmr->ifm_status = mii->mii_media_status;
 	ifmr->ifm_active = mii->mii_media_active;
+	AGE_UNLOCK(sc);
 }
 
 /*

Modified: stable/8/sys/dev/alc/if_alc.c
==============================================================================
--- stable/8/sys/dev/alc/if_alc.c	Sat Dec 31 01:07:01 2011	(r229057)
+++ stable/8/sys/dev/alc/if_alc.c	Sat Dec 31 01:08:31 2011	(r229058)
@@ -349,9 +349,9 @@ alc_mediastatus(struct ifnet *ifp, struc
 	mii = device_get_softc(sc->alc_miibus);
 
 	mii_pollstat(mii);
-	ALC_UNLOCK(sc);
 	ifmr->ifm_status = mii->mii_media_status;
 	ifmr->ifm_active = mii->mii_media_active;
+	ALC_UNLOCK(sc);
 }
 
 static int

Modified: stable/8/sys/dev/ale/if_ale.c
==============================================================================
--- stable/8/sys/dev/ale/if_ale.c	Sat Dec 31 01:07:01 2011	(r229057)
+++ stable/8/sys/dev/ale/if_ale.c	Sat Dec 31 01:08:31 2011	(r229058)
@@ -270,9 +270,9 @@ ale_mediastatus(struct ifnet *ifp, struc
 	mii = device_get_softc(sc->ale_miibus);
 
 	mii_pollstat(mii);
-	ALE_UNLOCK(sc);
 	ifmr->ifm_status = mii->mii_media_status;
 	ifmr->ifm_active = mii->mii_media_active;
+	ALE_UNLOCK(sc);
 }
 
 static int

Modified: stable/8/sys/dev/lge/if_lge.c
==============================================================================
--- stable/8/sys/dev/lge/if_lge.c	Sat Dec 31 01:07:01 2011	(r229057)
+++ stable/8/sys/dev/lge/if_lge.c	Sat Dec 31 01:08:31 2011	(r229058)
@@ -1430,9 +1430,9 @@ lge_ifmedia_sts(ifp, ifmr)
 	LGE_LOCK(sc);
 	mii = device_get_softc(sc->lge_miibus);
 	mii_pollstat(mii);
-	LGE_UNLOCK(sc);
 	ifmr->ifm_active = mii->mii_media_active;
 	ifmr->ifm_status = mii->mii_media_status;
+	LGE_UNLOCK(sc);
 
 	return;
 }

Modified: stable/8/sys/dev/msk/if_msk.c
==============================================================================
--- stable/8/sys/dev/msk/if_msk.c	Sat Dec 31 01:07:01 2011	(r229057)
+++ stable/8/sys/dev/msk/if_msk.c	Sat Dec 31 01:08:31 2011	(r229058)
@@ -995,9 +995,9 @@ msk_mediastatus(struct ifnet *ifp, struc
 	mii = device_get_softc(sc_if->msk_miibus);
 
 	mii_pollstat(mii);
-	MSK_IF_UNLOCK(sc_if);
 	ifmr->ifm_active = mii->mii_media_active;
 	ifmr->ifm_status = mii->mii_media_status;
+	MSK_IF_UNLOCK(sc_if);
 }
 
 static int

Modified: stable/8/sys/dev/nfe/if_nfe.c
==============================================================================
--- stable/8/sys/dev/nfe/if_nfe.c	Sat Dec 31 01:07:01 2011	(r229057)
+++ stable/8/sys/dev/nfe/if_nfe.c	Sat Dec 31 01:08:31 2011	(r229058)
@@ -2952,10 +2952,10 @@ nfe_ifmedia_sts(struct ifnet *ifp, struc
 	NFE_LOCK(sc);
 	mii = device_get_softc(sc->nfe_miibus);
 	mii_pollstat(mii);
-	NFE_UNLOCK(sc);
 
 	ifmr->ifm_active = mii->mii_media_active;
 	ifmr->ifm_status = mii->mii_media_status;
+	NFE_UNLOCK(sc);
 }
 
 

Modified: stable/8/sys/dev/nge/if_nge.c
==============================================================================
--- stable/8/sys/dev/nge/if_nge.c	Sat Dec 31 01:07:01 2011	(r229057)
+++ stable/8/sys/dev/nge/if_nge.c	Sat Dec 31 01:08:31 2011	(r229058)
@@ -2281,9 +2281,9 @@ nge_mediastatus(struct ifnet *ifp, struc
 	NGE_LOCK(sc);
 	mii = device_get_softc(sc->nge_miibus);
 	mii_pollstat(mii);
-	NGE_UNLOCK(sc);
 	ifmr->ifm_active = mii->mii_media_active;
 	ifmr->ifm_status = mii->mii_media_status;
+	NGE_UNLOCK(sc);
 }
 
 static int

Modified: stable/8/sys/dev/nve/if_nve.c
==============================================================================
--- stable/8/sys/dev/nve/if_nve.c	Sat Dec 31 01:07:01 2011	(r229057)
+++ stable/8/sys/dev/nve/if_nve.c	Sat Dec 31 01:08:31 2011	(r229058)
@@ -1202,10 +1202,10 @@ nve_ifmedia_sts(struct ifnet *ifp, struc
 	NVE_LOCK(sc);
 	mii = device_get_softc(sc->miibus);
 	mii_pollstat(mii);
-	NVE_UNLOCK(sc);
 
 	ifmr->ifm_active = mii->mii_media_active;
 	ifmr->ifm_status = mii->mii_media_status;
+	NVE_UNLOCK(sc);
 
 	return;
 }

Modified: stable/8/sys/dev/re/if_re.c
==============================================================================
--- stable/8/sys/dev/re/if_re.c	Sat Dec 31 01:07:01 2011	(r229057)
+++ stable/8/sys/dev/re/if_re.c	Sat Dec 31 01:08:31 2011	(r229058)
@@ -3214,9 +3214,9 @@ re_ifmedia_sts(struct ifnet *ifp, struct
 
 	RL_LOCK(sc);
 	mii_pollstat(mii);
-	RL_UNLOCK(sc);
 	ifmr->ifm_active = mii->mii_media_active;
 	ifmr->ifm_status = mii->mii_media_status;
+	RL_UNLOCK(sc);
 }
 
 static int

Modified: stable/8/sys/dev/sge/if_sge.c
==============================================================================
--- stable/8/sys/dev/sge/if_sge.c	Sat Dec 31 01:07:01 2011	(r229057)
+++ stable/8/sys/dev/sge/if_sge.c	Sat Dec 31 01:08:31 2011	(r229058)
@@ -1746,9 +1746,9 @@ sge_ifmedia_sts(struct ifnet *ifp, struc
 		return;
 	}
 	mii_pollstat(mii);
-	SGE_UNLOCK(sc);
 	ifmr->ifm_active = mii->mii_media_active;
 	ifmr->ifm_status = mii->mii_media_status;
+	SGE_UNLOCK(sc);
 }
 
 static int

Modified: stable/8/sys/dev/sis/if_sis.c
==============================================================================
--- stable/8/sys/dev/sis/if_sis.c	Sat Dec 31 01:07:01 2011	(r229057)
+++ stable/8/sys/dev/sis/if_sis.c	Sat Dec 31 01:08:31 2011	(r229058)
@@ -2112,9 +2112,9 @@ sis_ifmedia_sts(struct ifnet *ifp, struc
 	SIS_LOCK(sc);
 	mii = device_get_softc(sc->sis_miibus);
 	mii_pollstat(mii);
-	SIS_UNLOCK(sc);
 	ifmr->ifm_active = mii->mii_media_active;
 	ifmr->ifm_status = mii->mii_media_status;
+	SIS_UNLOCK(sc);
 }
 
 static int

Modified: stable/8/sys/dev/vge/if_vge.c
==============================================================================
--- stable/8/sys/dev/vge/if_vge.c	Sat Dec 31 01:07:01 2011	(r229057)
+++ stable/8/sys/dev/vge/if_vge.c	Sat Dec 31 01:08:31 2011	(r229058)
@@ -2173,9 +2173,9 @@ vge_ifmedia_sts(struct ifnet *ifp, struc
 		return;
 	}
 	mii_pollstat(mii);
-	VGE_UNLOCK(sc);
 	ifmr->ifm_active = mii->mii_media_active;
 	ifmr->ifm_status = mii->mii_media_status;
+	VGE_UNLOCK(sc);
 }
 
 static void

Modified: stable/8/sys/dev/vr/if_vr.c
==============================================================================
--- stable/8/sys/dev/vr/if_vr.c	Sat Dec 31 01:07:01 2011	(r229057)
+++ stable/8/sys/dev/vr/if_vr.c	Sat Dec 31 01:08:31 2011	(r229058)
@@ -2155,9 +2155,9 @@ vr_ifmedia_sts(struct ifnet *ifp, struct
 		return;
 	}
 	mii_pollstat(mii);
-	VR_UNLOCK(sc);
 	ifmr->ifm_active = mii->mii_media_active;
 	ifmr->ifm_status = mii->mii_media_status;
+	VR_UNLOCK(sc);
 }
 
 static int

Modified: stable/8/sys/dev/vte/if_vte.c
==============================================================================
--- stable/8/sys/dev/vte/if_vte.c	Sat Dec 31 01:07:01 2011	(r229057)
+++ stable/8/sys/dev/vte/if_vte.c	Sat Dec 31 01:08:31 2011	(r229058)
@@ -284,9 +284,9 @@ vte_mediastatus(struct ifnet *ifp, struc
 	mii = device_get_softc(sc->vte_miibus);
 
 	mii_pollstat(mii);
-	VTE_UNLOCK(sc);
 	ifmr->ifm_status = mii->mii_media_status;
 	ifmr->ifm_active = mii->mii_media_active;
+	VTE_UNLOCK(sc);
 }
 
 static int

Modified: stable/8/sys/mips/atheros/if_arge.c
==============================================================================
--- stable/8/sys/mips/atheros/if_arge.c	Sat Dec 31 01:07:01 2011	(r229057)
+++ stable/8/sys/mips/atheros/if_arge.c	Sat Dec 31 01:08:31 2011	(r229058)
@@ -1112,9 +1112,9 @@ arge_ifmedia_sts(struct ifnet *ifp, stru
 	mii = device_get_softc(sc->arge_miibus);
 	ARGE_LOCK(sc);
 	mii_pollstat(mii);
-	ARGE_UNLOCK(sc);
 	ifmr->ifm_active = mii->mii_media_active;
 	ifmr->ifm_status = mii->mii_media_status;
+	ARGE_UNLOCK(sc);
 }
 
 struct arge_dmamap_arg {

Modified: stable/8/sys/mips/idt/if_kr.c
==============================================================================
--- stable/8/sys/mips/idt/if_kr.c	Sat Dec 31 01:07:01 2011	(r229057)
+++ stable/8/sys/mips/idt/if_kr.c	Sat Dec 31 01:08:31 2011	(r229058)
@@ -945,9 +945,9 @@ kr_ifmedia_sts(struct ifnet *ifp, struct
 	mii = device_get_softc(sc->kr_miibus);
 	KR_LOCK(sc);
 	mii_pollstat(mii);
-	KR_UNLOCK(sc);
 	ifmr->ifm_active = mii->mii_media_active;
 	ifmr->ifm_status = mii->mii_media_status;
+	KR_UNLOCK(sc);
 }
 
 struct kr_dmamap_arg {

Modified: stable/8/sys/pci/if_rl.c
==============================================================================
--- stable/8/sys/pci/if_rl.c	Sat Dec 31 01:07:01 2011	(r229057)
+++ stable/8/sys/pci/if_rl.c	Sat Dec 31 01:08:31 2011	(r229058)
@@ -1797,9 +1797,9 @@ rl_ifmedia_sts(struct ifnet *ifp, struct
 
 	RL_LOCK(sc);
 	mii_pollstat(mii);
-	RL_UNLOCK(sc);
 	ifmr->ifm_active = mii->mii_media_active;
 	ifmr->ifm_status = mii->mii_media_status;
+	RL_UNLOCK(sc);
 }
 
 static int



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