svn commit: r229057 - in stable/9/sys: 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

Pyun YongHyeon yongari at FreeBSD.org
Sat Dec 31 01:07:02 UTC 2011


Author: yongari
Date: Sat Dec 31 01:07:01 2011
New Revision: 229057
URL: http://svn.freebsd.org/changeset/base/229057

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/9/sys/dev/age/if_age.c
  stable/9/sys/dev/alc/if_alc.c
  stable/9/sys/dev/ale/if_ale.c
  stable/9/sys/dev/lge/if_lge.c
  stable/9/sys/dev/msk/if_msk.c
  stable/9/sys/dev/nfe/if_nfe.c
  stable/9/sys/dev/nge/if_nge.c
  stable/9/sys/dev/nve/if_nve.c
  stable/9/sys/dev/re/if_re.c
  stable/9/sys/dev/sge/if_sge.c
  stable/9/sys/dev/sis/if_sis.c
  stable/9/sys/dev/vge/if_vge.c
  stable/9/sys/dev/vr/if_vr.c
  stable/9/sys/dev/vte/if_vte.c
  stable/9/sys/mips/atheros/if_arge.c
  stable/9/sys/mips/idt/if_kr.c
  stable/9/sys/pci/if_rl.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/amd64/include/xen/   (props changed)
  stable/9/sys/boot/   (props changed)
  stable/9/sys/boot/i386/efi/   (props changed)
  stable/9/sys/boot/ia64/efi/   (props changed)
  stable/9/sys/boot/ia64/ski/   (props changed)
  stable/9/sys/boot/powerpc/boot1.chrp/   (props changed)
  stable/9/sys/boot/powerpc/ofw/   (props changed)
  stable/9/sys/cddl/contrib/opensolaris/   (props changed)
  stable/9/sys/conf/   (props changed)
  stable/9/sys/contrib/dev/acpica/   (props changed)
  stable/9/sys/contrib/octeon-sdk/   (props changed)
  stable/9/sys/contrib/pf/   (props changed)
  stable/9/sys/contrib/x86emu/   (props changed)

Modified: stable/9/sys/dev/age/if_age.c
==============================================================================
--- stable/9/sys/dev/age/if_age.c	Sat Dec 31 01:06:51 2011	(r229056)
+++ stable/9/sys/dev/age/if_age.c	Sat Dec 31 01:07:01 2011	(r229057)
@@ -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/9/sys/dev/alc/if_alc.c
==============================================================================
--- stable/9/sys/dev/alc/if_alc.c	Sat Dec 31 01:06:51 2011	(r229056)
+++ stable/9/sys/dev/alc/if_alc.c	Sat Dec 31 01:07:01 2011	(r229057)
@@ -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/9/sys/dev/ale/if_ale.c
==============================================================================
--- stable/9/sys/dev/ale/if_ale.c	Sat Dec 31 01:06:51 2011	(r229056)
+++ stable/9/sys/dev/ale/if_ale.c	Sat Dec 31 01:07:01 2011	(r229057)
@@ -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/9/sys/dev/lge/if_lge.c
==============================================================================
--- stable/9/sys/dev/lge/if_lge.c	Sat Dec 31 01:06:51 2011	(r229056)
+++ stable/9/sys/dev/lge/if_lge.c	Sat Dec 31 01:07:01 2011	(r229057)
@@ -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/9/sys/dev/msk/if_msk.c
==============================================================================
--- stable/9/sys/dev/msk/if_msk.c	Sat Dec 31 01:06:51 2011	(r229056)
+++ stable/9/sys/dev/msk/if_msk.c	Sat Dec 31 01:07:01 2011	(r229057)
@@ -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/9/sys/dev/nfe/if_nfe.c
==============================================================================
--- stable/9/sys/dev/nfe/if_nfe.c	Sat Dec 31 01:06:51 2011	(r229056)
+++ stable/9/sys/dev/nfe/if_nfe.c	Sat Dec 31 01:07:01 2011	(r229057)
@@ -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/9/sys/dev/nge/if_nge.c
==============================================================================
--- stable/9/sys/dev/nge/if_nge.c	Sat Dec 31 01:06:51 2011	(r229056)
+++ stable/9/sys/dev/nge/if_nge.c	Sat Dec 31 01:07:01 2011	(r229057)
@@ -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/9/sys/dev/nve/if_nve.c
==============================================================================
--- stable/9/sys/dev/nve/if_nve.c	Sat Dec 31 01:06:51 2011	(r229056)
+++ stable/9/sys/dev/nve/if_nve.c	Sat Dec 31 01:07:01 2011	(r229057)
@@ -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/9/sys/dev/re/if_re.c
==============================================================================
--- stable/9/sys/dev/re/if_re.c	Sat Dec 31 01:06:51 2011	(r229056)
+++ stable/9/sys/dev/re/if_re.c	Sat Dec 31 01:07:01 2011	(r229057)
@@ -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/9/sys/dev/sge/if_sge.c
==============================================================================
--- stable/9/sys/dev/sge/if_sge.c	Sat Dec 31 01:06:51 2011	(r229056)
+++ stable/9/sys/dev/sge/if_sge.c	Sat Dec 31 01:07:01 2011	(r229057)
@@ -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/9/sys/dev/sis/if_sis.c
==============================================================================
--- stable/9/sys/dev/sis/if_sis.c	Sat Dec 31 01:06:51 2011	(r229056)
+++ stable/9/sys/dev/sis/if_sis.c	Sat Dec 31 01:07:01 2011	(r229057)
@@ -2109,9 +2109,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/9/sys/dev/vge/if_vge.c
==============================================================================
--- stable/9/sys/dev/vge/if_vge.c	Sat Dec 31 01:06:51 2011	(r229056)
+++ stable/9/sys/dev/vge/if_vge.c	Sat Dec 31 01:07:01 2011	(r229057)
@@ -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/9/sys/dev/vr/if_vr.c
==============================================================================
--- stable/9/sys/dev/vr/if_vr.c	Sat Dec 31 01:06:51 2011	(r229056)
+++ stable/9/sys/dev/vr/if_vr.c	Sat Dec 31 01:07:01 2011	(r229057)
@@ -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/9/sys/dev/vte/if_vte.c
==============================================================================
--- stable/9/sys/dev/vte/if_vte.c	Sat Dec 31 01:06:51 2011	(r229056)
+++ stable/9/sys/dev/vte/if_vte.c	Sat Dec 31 01:07:01 2011	(r229057)
@@ -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/9/sys/mips/atheros/if_arge.c
==============================================================================
--- stable/9/sys/mips/atheros/if_arge.c	Sat Dec 31 01:06:51 2011	(r229056)
+++ stable/9/sys/mips/atheros/if_arge.c	Sat Dec 31 01:07:01 2011	(r229057)
@@ -1199,9 +1199,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/9/sys/mips/idt/if_kr.c
==============================================================================
--- stable/9/sys/mips/idt/if_kr.c	Sat Dec 31 01:06:51 2011	(r229056)
+++ stable/9/sys/mips/idt/if_kr.c	Sat Dec 31 01:07:01 2011	(r229057)
@@ -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/9/sys/pci/if_rl.c
==============================================================================
--- stable/9/sys/pci/if_rl.c	Sat Dec 31 01:06:51 2011	(r229056)
+++ stable/9/sys/pci/if_rl.c	Sat Dec 31 01:07:01 2011	(r229057)
@@ -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


More information about the svn-src-stable-9 mailing list