From nobody Wed Dec 17 21:16:02 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4dWmmz27X2z6LR5r for ; Wed, 17 Dec 2025 21:16:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dWmmy6mQqz4QdM for ; Wed, 17 Dec 2025 21:16:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1766006163; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xX3VOYVTGtjZHP8GC8J+zIvm5EeZf/E6V1198V1KG9Y=; b=EG+Kn70xWRv8QNMX/YcfYN2Jkik3TiBAap8y4u4hJvS2b905H+DUFTWru8gqrr8G6BK6C3 MGE5TsRUA70sjSNyvKG7zPLoVoelAuX2LM2/lvzNBz/hYiOo5D47KHy+QMWLTfh5xEP/5e tN2eLOhdtObmUacTh3NmJ8i68LGIp2s9hkTCtof49nSFCsTIdVYrISXgj4406UTkSa7h/y 3uhgbrSCNmhe0oJQR3eqbb0O9ZbLlhSt66gdhbAUnzNJZcwAv+OpR+qwp9HZ8ELQeopJ+m wT0SLSrnvfvT0D4zyMCV6hiunRxxrqdGyobQvaCyGJjZnRBqKQVwwoZ1qliqmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1766006163; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xX3VOYVTGtjZHP8GC8J+zIvm5EeZf/E6V1198V1KG9Y=; b=VNf4K0AmQwyRCPYSt+lLsiLnCO9t6Z4fk6nvKi1mNqLBS1KDvQT4q8zqFHXHOJ2v0HjDd4 r7tZRF559EoEeMM5ZDwOIOe8jKzFFrdoF0USlzWknA3vNSXufgz/TaYkMHfGq7qqqJXjFz AvphhklGsqMn+z8gtxyX6mqieR6JUUiJaQxqvW7O2emcowshE5XCxyr2hVXKOU9gCHX8pH jveI09jvAsXvcdAUZ7OWrTDrCIi9t8fUH/fYcz9a/OpmRJoa1YFcsB4WL2s2fp9BuLItOj RiklhgMU57NrYHhWXx2BjdoSchsJSWAyufBAj52LN736+V6bskrukR65lin3sg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1766006163; a=rsa-sha256; cv=none; b=n+fN23x09rQ6yhxAAcstsCG+g8T0ntSrtqSiWCKM/RR8eYEH8foKWVihoTL3DO/SBKGVok l9F+0QTDBgYSVY9Nhj0VJUe82eam5ZeWHp4gkC/eSgb31BAj5K6tynyKOKY6pbdEs4ZPV/ CJseEJgZXtyNGDEYC9tgFIbBzUs0ACSOvYNxRecLWQeubvAAtlEy32348GWclfPixtVFZe faFxxtPtiios42WBe5Ou0uwDSOYzqJwkd1HvlaMzVOc+GRoLzHdyRA7TS1copqUCsCccN8 +iGHO4fAzkQytvU5zRMYUe7XS+xa3E3tF/XNXACAqTFWKkquaByoYhPZqKz/bA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4dWmmy51NWz16nx for ; Wed, 17 Dec 2025 21:16:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 4167e by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 17 Dec 2025 21:16:02 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: d4062b9f16e4 - main - vlan: plug a new panic associated with interface removal List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d4062b9f16e46f039f2b5b40dd35592b5dabf00c Auto-Submitted: auto-generated Date: Wed, 17 Dec 2025 21:16:02 +0000 Message-Id: <69431d92.4167e.7b9e2bd6@gitrepo.freebsd.org> The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=d4062b9f16e46f039f2b5b40dd35592b5dabf00c commit d4062b9f16e46f039f2b5b40dd35592b5dabf00c Author: Gleb Smirnoff AuthorDate: 2025-12-17 21:05:04 +0000 Commit: Gleb Smirnoff CommitDate: 2025-12-17 21:13:42 +0000 vlan: plug a new panic associated with interface removal The ac6a7f621668 enabled execution of vlan_clone_dump_nl(), which previously was effectively disabled. The function itself was added back in 089104e0e01f0. This exposed a bug when Netlink dumps info on all interfaces using a dangerous KPI if_foreach_sleep(), which may call its callbacks on completely detached interfaces, hanging on the last reference. The ifc_dump_ifp_nl_default() is able to digest such interface without a panic, but vlan_clone_dump_nl() can't. Neither of the above revisions is the actual culprit, rather it is design problem of detaching interfaces and if_foreach_sleep(). Plug the problem with removing pointer to freed memory on detach and making a NULL check later. Reported by: pho --- sys/net/if_vlan.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c index 61000018e5a4..afc3fa3fc79e 100644 --- a/sys/net/if_vlan.c +++ b/sys/net/if_vlan.c @@ -1341,12 +1341,19 @@ vlan_clone_modify_nl(struct ifnet *ifp, struct ifc_data_nl *ifd) static void vlan_clone_dump_nl(struct ifnet *ifp, struct nl_writer *nw) { + struct ifvlan *ifv; uint32_t parent_index = 0; uint16_t vlan_id = 0; uint16_t vlan_proto = 0; VLAN_SLOCK(); - struct ifvlan *ifv = ifp->if_softc; + if (__predict_false((ifv = ifp->if_softc) == NULL)) { + /* + * XXXGL: the interface already went through if_dead(). This + * check to be removed when we got better interface removal. + */ + return; + } if (TRUNK(ifv) != NULL) parent_index = PARENT(ifv)->if_index; vlan_id = ifv->ifv_vid; @@ -1390,6 +1397,7 @@ vlan_clone_destroy(struct if_clone *ifc, struct ifnet *ifp, uint32_t flags) */ taskqueue_drain(taskqueue_thread, &ifv->lladdr_task); NET_EPOCH_WAIT(); + ifp->if_softc = NULL; if_free(ifp); free(ifv, M_VLAN); if (unit != IF_DUNIT_NONE)