From nobody Fri May 19 13:42:45 2023 X-Original-To: dev-commits-src-main@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 4QN7M94FFTz4By6D; Fri, 19 May 2023 13:42:45 +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 4QN7M93j0xz3kcj; Fri, 19 May 2023 13:42:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1684503765; 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=LPwlxVY7Qyb5megpfPc71o9QsxP2Sm6zi5GD0MENxkA=; b=rgxtbD7HRW0w3fbwi4WQGa6hZ+8yKY7u9++EX4KtjkezIRC8/v3IOp0NuS8roUroW/LG+r pZAUwMxsmmiAbz1R34+1g8kOcaF4d1jgp2AXJbGgMX5rMR/GpjXm+ftSJOXIrkaGbze9yT p+VNFnN9P+h3JFUikFdGGlZAC1ngITHo8GXbfCYtDs1if4mfUTDDA/2IRryQX2HSLbL59q 5wv2VhWeruxGlbkZ/L4/9QjKox4xVZw8LhJhuPAJKNouBc4+W9EA6XDasenaqjl+NJQ1T0 yJFWxlMirJFXlDHFRcKK1MpSQkOvpls9OYrXa/5uZOMXRl+3ktMnWyvFqo6YNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1684503765; 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=LPwlxVY7Qyb5megpfPc71o9QsxP2Sm6zi5GD0MENxkA=; b=e21+jfpdopNgbCCW7vq5DV4vCXlZeYmIdNuMWuPKJjJcgCbXMcNls0lJAz0z9k2P8J+ouK 6VF4f8SOt1c0l9m/FzYRvYLojbH8x4y8YyiZbMRd/Hdh3u/DgzG6uDlvnc3fhMCn9raxLq Nmvbp10dVO4lOkzlqHKpS0QJA1IV600TehbrIBr+hicKfgIVTmOSM0h0RebNRg43BCbqWL KNYZrlRMn1zYcP61rOAGftLyqyMU0Hqzwvqk/LA3cF8Lf+ivsN6NEPCRJ+6vDWUCpIbtTN QO44Q4apqhyZZiwyGykJcwWPZbUYaVmoFVYTdpgZNtaKCsQhbOci3BzeHSIsuw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1684503765; a=rsa-sha256; cv=none; b=XpD/oOqq1g5zNkROyY/xzgQLVbXAsKEoT1N8RBrU662WZGfmiODJO59q6PC5ASKx3ZvR8U lK+8XQWJkHj7UMT4k8/uUfLn3MwARmTl3i6vL1Eo8r3Kc/gTnKAZmG7J/SO/89Ny82frms LS3Ud94MNAqexK5GVH0xBYfKO9dIPn4CVExbWNlONFw0Y07RmDyBE9r5fuuYHLnqosci02 j0ia6cRtL9OAX61kyT86VpqIhBMZfGEHtI4V1wtlXvsm1A/dHBeARcVFpuwMjJ9TZ5ECZc JvHXzFnBu+Zlem8S703squptVnAJfbcwb++RNEGDh8m57fJap52tavheb8Xg2g== 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 4QN7M92kr2zVhM; Fri, 19 May 2023 13:42:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 34JDgjgY059686; Fri, 19 May 2023 13:42:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 34JDgjBN059685; Fri, 19 May 2023 13:42:45 GMT (envelope-from git) Date: Fri, 19 May 2023 13:42:45 GMT Message-Id: <202305191342.34JDgjBN059685@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: f3546eacf0da - main - if_bridge: fix potential panic List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: f3546eacf0daac55fe08b6ad5849b0e440f75ffb Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=f3546eacf0daac55fe08b6ad5849b0e440f75ffb commit f3546eacf0daac55fe08b6ad5849b0e440f75ffb Author: Kristof Provost AuthorDate: 2023-05-18 18:04:45 +0000 Commit: Kristof Provost CommitDate: 2023-05-19 13:26:52 +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 --- 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 d78c647df0b4..9fe915d31283 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -2940,12 +2940,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); @@ -2953,6 +2953,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;