Don't call enable_all_rings if the adapter has been freed.
This is a subtle use-after-free race that results in some very undesirable
hang behaviour.
Reviewed by: pkelsey
Obtained from: Kip Macy, NextBSD (91a9bd1dbb
)
This commit is contained in:
parent
c80b6ca937
commit
15b1492c9b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=287543
@ -2841,10 +2841,12 @@ void
|
|||||||
netmap_detach(struct ifnet *ifp)
|
netmap_detach(struct ifnet *ifp)
|
||||||
{
|
{
|
||||||
struct netmap_adapter *na = NA(ifp);
|
struct netmap_adapter *na = NA(ifp);
|
||||||
|
int skip;
|
||||||
|
|
||||||
if (!na)
|
if (!na)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
skip = 0;
|
||||||
NMG_LOCK();
|
NMG_LOCK();
|
||||||
netmap_disable_all_rings(ifp);
|
netmap_disable_all_rings(ifp);
|
||||||
na->ifp = NULL;
|
na->ifp = NULL;
|
||||||
@ -2856,10 +2858,11 @@ netmap_detach(struct ifnet *ifp)
|
|||||||
* the driver is gone.
|
* the driver is gone.
|
||||||
*/
|
*/
|
||||||
if (na->na_flags & NAF_NATIVE) {
|
if (na->na_flags & NAF_NATIVE) {
|
||||||
netmap_adapter_put(na);
|
skip = netmap_adapter_put(na);
|
||||||
}
|
}
|
||||||
/* give them a chance to notice */
|
/* give them a chance to notice */
|
||||||
netmap_enable_all_rings(ifp);
|
if (skip == 0)
|
||||||
|
netmap_enable_all_rings(ifp);
|
||||||
NMG_UNLOCK();
|
NMG_UNLOCK();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user