From nobody Sun Jul 09 15:25:17 2023 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 4QzWCy2HC6z4mW8p; Sun, 9 Jul 2023 15:25:18 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QzWCy1pL4z4MyM; Sun, 9 Jul 2023 15:25:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1688916318; 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=IZgHrqKC406Dvv6hAtwbZx9zjAxnccAfSdLAzes4HmU=; b=iwxu7ur6UrNgTWU1EEpLaYBHqIEygVVWmm9BJERe4+4+/AsCSPekT17t059vLcZmzPAqq4 zEJ0GUqt6kRUyyDMH8l1cQiuot1WJj1nbIHHX+wdlJKa7uYir5d37FaBxuPOSURx/GE2Kh vBsyVMXtIS8aqq0H/Mf+LGTdhvZbwjWWqQuJYq3u4BpGIJlxpXnGW3+9U0V2ylotBQfPg5 FAxbp3FsstFXtCTFAy+FA6CaRhvuG6SpXZM2YrGPdue7ZIM1giDF4P/RtDzgrmE+nq0ImI MPULoC9XP8vhs67umxpLPA42EOrCdm5LO9qtzJZjKt09nHClq24G//xVMMrMNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1688916318; 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=IZgHrqKC406Dvv6hAtwbZx9zjAxnccAfSdLAzes4HmU=; b=MpiJsROsDNXlnyuIdDw6orqKCz/Wi9zZ0feniFz1JKikbQ4DO4pSytf84ONRMq4xo1sc13 w+95WAPL9yS8wIigr67VPie6Y2yFaClYg768oIv4C/1wtfJv/tTGa/8bJejGbZYFwKzhXF Sqrgbb0Cji0yFGvXKADO3pCihPyplBIkckScW7m5UBuKdMlUMlTgekiYy8PExHa04aOOVc 2gMpqSzZoE4OgnlO37sPlckJcrw58KUUn/AoHg51qVMkaHlpnNitixnvSagl1JhlAjS2oe nIfg4WJECxPShwQuZRFjLHJg2Naoen6w6kp79F8FHHBIDZ47lpe56jGOjvbJAQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1688916318; a=rsa-sha256; cv=none; b=UHfZWFfI4bW6VKNU0A0F7t6d+Ch96G6SYAj9DU1fCaYAGrrQbqzUFuS9MoO+V0LaQZTGu0 hfhd3zSO8oVvHrBjqjG8yBKr1jUs2FJoqBfGe0L1D3fHTfJXPUNlx4HB8s0STXurbkTU3K NCxsayR1++MB/aolrkW0Pz77OjZuuS9zLNXf3VYqTbOBNv88sdvQzJH8DTUn9jia0h69Ho 0Vnc2ERLKg0P7XKE5m4KBgmK3OAmfJf9TxYHE0/pho0zM61TtUMWXMJC6zaYRYxq/oD2Bc IoUnMYduyQq4ZQREnZXTWbzbfFtKdY3BY3lbgIDcTdGglROA8gGt8ssBiQSivw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4QzWCy0dY4z177l; Sun, 9 Jul 2023 15:25:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 369FPH2k052930; Sun, 9 Jul 2023 15:25:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 369FPH3F052929; Sun, 9 Jul 2023 15:25:17 GMT (envelope-from git) Date: Sun, 9 Jul 2023 15:25:17 GMT Message-Id: <202307091525.369FPH3F052929@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 9835aa0d7dea - stable/12 - if_bridge: fix potential panic 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 9835aa0d7dea7776165c770d059de4d9ead86dd1 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=9835aa0d7dea7776165c770d059de4d9ead86dd1 commit 9835aa0d7dea7776165c770d059de4d9ead86dd1 Author: Kristof Provost AuthorDate: 2023-05-18 18:04:45 +0000 Commit: Kristof Provost CommitDate: 2023-07-09 12:27:01 +0000 if_bridge: fix potential panic When a new bridge_rtnode is added it is added with a NULL brt_dst. The brt_dst is set after the entry is added. This means there's a small window where another core could also attempt to add this node, leading to the code attempting to log that the MAC addresses moved to a new interface. Aside from that being a spurious log entry it also panics, because obif is NULL (and we attempt to dereference it). Avoid this by settings brt_dst before we insert the bridge_rtnode. Assert that obif is non-NULL, as an extra precaution. Reported by: olivier@ Reviewed by: zlei@ Differential Revision: https://reviews.freebsd.org/D40147 (cherry picked from commit f3546eacf0daac55fe08b6ad5849b0e440f75ffb) --- sys/net/if_bridge.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c index 28e8e8856b8e..23c1c4171761 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -2882,12 +2882,12 @@ bridge_rtupdate(struct bridge_softc *sc, const uint8_t *dst, uint16_t vlan, memcpy(brt->brt_addr, dst, ETHER_ADDR_LEN); brt->brt_vlan = vlan; + brt->brt_dst = bif; if ((error = bridge_rtnode_insert(sc, brt)) != 0) { uma_zfree(V_bridge_rtnode_zone, brt); BRIDGE_RT_UNLOCK(sc); return (error); } - brt->brt_dst = bif; bif->bif_addrcnt++; BRIDGE_RT_UNLOCK(sc); @@ -2895,6 +2895,8 @@ bridge_rtupdate(struct bridge_softc *sc, const uint8_t *dst, uint16_t vlan, if ((brt->brt_flags & IFBAF_TYPEMASK) == IFBAF_DYNAMIC && (obif = brt->brt_dst) != bif) { + MPASS(obif != NULL); + BRIDGE_RT_LOCK(sc); brt->brt_dst->bif_addrcnt--; brt->brt_dst = bif;