mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
fix use after free when releasing a netmap adapter.
Submitted by: Giuseppe Lettieri
This commit is contained in:
parent
88c4b8d145
commit
fb25194fb0
2 changed files with 10 additions and 5 deletions
|
|
@ -2208,9 +2208,14 @@ netmap_detach(struct ifnet *ifp)
|
|||
|
||||
NMG_LOCK();
|
||||
netmap_disable_all_rings(ifp);
|
||||
netmap_adapter_put(na);
|
||||
na->ifp = NULL;
|
||||
netmap_enable_all_rings(ifp);
|
||||
if (!netmap_adapter_put(na)) {
|
||||
/* someone is still using the adapter,
|
||||
* tell them that the interface is gone
|
||||
*/
|
||||
na->ifp = NULL;
|
||||
/* give them a chance to notice */
|
||||
netmap_enable_all_rings(ifp);
|
||||
}
|
||||
NMG_UNLOCK();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -899,11 +899,11 @@ void __netmap_adapter_get(struct netmap_adapter *na);
|
|||
int __netmap_adapter_put(struct netmap_adapter *na);
|
||||
|
||||
#define netmap_adapter_put(na) \
|
||||
do { \
|
||||
({ \
|
||||
struct netmap_adapter *__na = na; \
|
||||
D("putting %p:%s (%d)", __na, NM_IFPNAME(__na->ifp), __na->na_refcount); \
|
||||
__netmap_adapter_put(__na); \
|
||||
} while (0)
|
||||
})
|
||||
|
||||
#else /* !NM_DEBUG_PUTGET */
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue