git: 2265cf938ec3 - stable/13 - ifnet: Fix decreasing the vnet interface count
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 20 Mar 2026 10:04:16 UTC
The branch stable/13 has been updated by zlei:
URL: https://cgit.FreeBSD.org/src/commit/?id=2265cf938ec30d9658d787d4128541cc7b9bd67a
commit 2265cf938ec30d9658d787d4128541cc7b9bd67a
Author: Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2026-03-16 16:20:08 +0000
Commit: Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2026-03-20 10:03:43 +0000
ifnet: Fix decreasing the vnet interface count
It should be decreased only when the interface has been successfully
removed from the "active" list.
This prevents vnet_if_return() from potential OOB writes to the
allocated memory "pending".
Reviewed by: kp, pouria
Fixes: a779388f8bb3 if: Protect V_ifnet in vnet_if_return()
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D55873
(cherry picked from commit 8065ff63c0e5c3bb4abb02f55b20cb47bb51d1a7)
(cherry picked from commit 1b7687f053afcf251ee7643ee5a4f22a225f4a02)
(cherry picked from commit 47339e4a9209c1d1323f58d792e277792990e060)
---
sys/net/if.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sys/net/if.c b/sys/net/if.c
index c642e99136d8..3835ed57fea9 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -485,14 +485,14 @@ if_unlink_ifnet(struct ifnet *ifp, bool vmove)
CK_STAILQ_FOREACH(iter, &V_ifnet, if_link)
if (iter == ifp) {
CK_STAILQ_REMOVE(&V_ifnet, ifp, ifnet, if_link);
+#ifdef VIMAGE
+ curvnet->vnet_ifcnt--;
+#endif
if (!vmove)
ifp->if_flags |= IFF_DYING;
found = 1;
break;
}
-#ifdef VIMAGE
- curvnet->vnet_ifcnt--;
-#endif
IFNET_WUNLOCK();
return (found);