From e9e549ef70ac54475c6443d33f91ec5d8721fd8d Mon Sep 17 00:00:00 2001 From: Pyun YongHyeon Date: Mon, 17 Oct 2011 19:51:38 +0000 Subject: [PATCH] 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) --- sys/dev/usb/net/if_aue.c | 2 +- sys/dev/usb/net/if_axe.c | 2 +- sys/dev/usb/net/if_mos.c | 2 +- sys/dev/usb/net/if_rue.c | 2 +- sys/dev/usb/net/if_udav.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/dev/usb/net/if_aue.c b/sys/dev/usb/net/if_aue.c index 86bfe20b432a..adf47f41ff07 100644 --- a/sys/dev/usb/net/if_aue.c +++ b/sys/dev/usb/net/if_aue.c @@ -1032,9 +1032,9 @@ aue_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr) AUE_LOCK(sc); mii_pollstat(mii); - AUE_UNLOCK(sc); ifmr->ifm_active = mii->mii_media_active; ifmr->ifm_status = mii->mii_media_status; + AUE_UNLOCK(sc); } /* diff --git a/sys/dev/usb/net/if_axe.c b/sys/dev/usb/net/if_axe.c index a440294ae345..b2aef680f527 100644 --- a/sys/dev/usb/net/if_axe.c +++ b/sys/dev/usb/net/if_axe.c @@ -452,9 +452,9 @@ axe_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr) AXE_LOCK(sc); mii_pollstat(mii); - AXE_UNLOCK(sc); ifmr->ifm_active = mii->mii_media_active; ifmr->ifm_status = mii->mii_media_status; + AXE_UNLOCK(sc); } static void diff --git a/sys/dev/usb/net/if_mos.c b/sys/dev/usb/net/if_mos.c index 0cbea915afbd..5fbbb393ddec 100644 --- a/sys/dev/usb/net/if_mos.c +++ b/sys/dev/usb/net/if_mos.c @@ -551,10 +551,10 @@ mos_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr) MOS_LOCK(sc); mii_pollstat(mii); - MOS_UNLOCK(sc); ifmr->ifm_active = mii->mii_media_active; ifmr->ifm_status = mii->mii_media_status; + MOS_UNLOCK(sc); } static void diff --git a/sys/dev/usb/net/if_rue.c b/sys/dev/usb/net/if_rue.c index 3e3a151da207..c874c1db5424 100644 --- a/sys/dev/usb/net/if_rue.c +++ b/sys/dev/usb/net/if_rue.c @@ -889,9 +889,9 @@ rue_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr) RUE_LOCK(sc); mii_pollstat(mii); - RUE_UNLOCK(sc); ifmr->ifm_active = mii->mii_media_active; ifmr->ifm_status = mii->mii_media_status; + RUE_UNLOCK(sc); } static void diff --git a/sys/dev/usb/net/if_udav.c b/sys/dev/usb/net/if_udav.c index ea3512773c22..e9a0504dfb50 100644 --- a/sys/dev/usb/net/if_udav.c +++ b/sys/dev/usb/net/if_udav.c @@ -751,9 +751,9 @@ udav_ifmedia_status(struct ifnet *ifp, struct ifmediareq *ifmr) UDAV_LOCK(sc); mii_pollstat(mii); - UDAV_UNLOCK(sc); ifmr->ifm_active = mii->mii_media_active; ifmr->ifm_status = mii->mii_media_status; + UDAV_UNLOCK(sc); } static void