Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Mar 2026 16:23:17 +0000
From:      Zhenlei Huang <zlei@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 8065ff63c0e5 - main - ifnet: Fix decreasing the vnet interface count
Message-ID:  <69b82e75.1d20a.2a36611d@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by zlei:

URL: https://cgit.FreeBSD.org/src/commit/?id=8065ff63c0e5c3bb4abb02f55b20cb47bb51d1a7

commit 8065ff63c0e5c3bb4abb02f55b20cb47bb51d1a7
Author:     Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2026-03-16 16:20:08 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2026-03-16 16:20:08 +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
---
 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 96da4da8c6c1..c3f31a28b40d 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -447,14 +447,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);


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69b82e75.1d20a.2a36611d>