aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/netmap
diff options
context:
space:
mode:
authorAdrian Chadd <adrian@FreeBSD.org>2015-09-07 23:16:39 +0000
committerAdrian Chadd <adrian@FreeBSD.org>2015-09-07 23:16:39 +0000
commit15b1492c9b09c465f5e13deb85292c0f2173c7fc (patch)
tree65d41346c0e215d91f84621d49ee3f0c3f0bc4fc /sys/dev/netmap
parentc80b6ca937d436f3acc02784343964400fc7deff (diff)
downloadsrc-15b1492c9b09c465f5e13deb85292c0f2173c7fc.tar.gz
src-15b1492c9b09c465f5e13deb85292c0f2173c7fc.zip
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 (https://github.com/NextBSD/NextBSD/commit/91a9bd1dbb33dafb41684d054e59d73976de9654)
Notes
Notes: svn path=/head/; revision=287543
Diffstat (limited to 'sys/dev/netmap')
-rw-r--r--sys/dev/netmap/netmap.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/sys/dev/netmap/netmap.c b/sys/dev/netmap/netmap.c
index 8094fe35256c..56bbf120caff 100644
--- a/sys/dev/netmap/netmap.c
+++ b/sys/dev/netmap/netmap.c
@@ -2841,10 +2841,12 @@ void
netmap_detach(struct ifnet *ifp)
{
struct netmap_adapter *na = NA(ifp);
+ int skip;
if (!na)
return;
+ skip = 0;
NMG_LOCK();
netmap_disable_all_rings(ifp);
na->ifp = NULL;
@@ -2856,10 +2858,11 @@ netmap_detach(struct ifnet *ifp)
* the driver is gone.
*/
if (na->na_flags & NAF_NATIVE) {
- netmap_adapter_put(na);
+ skip = netmap_adapter_put(na);
}
/* give them a chance to notice */
- netmap_enable_all_rings(ifp);
+ if (skip == 0)
+ netmap_enable_all_rings(ifp);
NMG_UNLOCK();
}