From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.222.198 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796529247; b=IBh7z4VRDzu4+q3h7mI4XCLRXQVjSlwivgZG0B5a4HegRPIxyzBSZKaYFJwLc42DSHfQ WQBHO4T24q4VUABCDInoQ2YvowyjpCQC2IEAo5bXhB4AGXymq97o3AV/+eiwIK4WhaKBP AeG1ZG6IHnGQ/rg0k8A6d2RhXFjdMwEB1NtF9s8DSadH6DIsw1NH+nIqldKKxmyU+lPOl HOKWc+G2aaCy+bP3DaSnQgPvhkkKioPl0Dbwg9c8GPrejEeRwmSP++z40SHE2IXeMOGQf MNKEGRwAal/u9Xo++fKaJq/2P0JGDh2RYIHetPhInHRPXv0awptJg6I1460VIf/ELeg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796529247; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:Message-ID:Subject:From:To:Cc:Content-Type; bh=C4KStiHTQ2qg/vGHdpfA48kZ7RveZ7zTCwE8DfhGNGU=; b=ggCR0aTQGYgkiJNxmXn5OecTiKFyamQjA57Wpf1Xd8JSi3pbLhDLuMDDqeCGz97ipBDM QVnX1ZJz40sOs7xn6Tsu34OqjYjW00GQMEO9qkNXNCvzY/hpC8v3lKKvdzSxpoiE1zgf5 ShGrgkeBhdbivPxZyfs22QWmBOOixPel9TjOPOTwED/nfpmoiQEKr6nvttZwwbhiJCFU1 EnvOkhUG8mpnj9e6UlGByKP6VEgB97OhUvyo7gBxjWRDZbI/jwI1hY4h+TyJybFDJy2M1 H9ulf2j010d5eRATUXxpRpK2w5rf7QBzGmoJhHgikMUvM490R6R6sihsONnmD9jwrMw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--willemb.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=WdVTq94z; arc=none smtp.remote-ip=209.85.222.198 Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8445606A31F for ; Sun, 6 Dec 2026 03:54:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B8445606A31F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--willemb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=WdVTq94z Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-93f33438950so429132885a.1 for ; Sat, 05 Dec 2026 19:54:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796529246; x=1797134046; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=C4KStiHTQ2qg/vGHdpfA48kZ7RveZ7zTCwE8DfhGNGU=; b=WdVTq94zvil1o1MHwrjFqoxqiwCyZiwOVMSuWlyqfHR2JmdrYt91KJa4lKQw5s22zN NCPGq8g6fnk4Mtg8wdB6J0aGlXeb2Ae8aQKvjHzNAkxCSFTUhvuRMhRY7hTCJP7HcZH4 VfmqG64w+wvJEovUqfK5gR8h+c2yOtcxwBCKopiP6rwoHpREDsEBx+eDDgmrG98T9uRH 8hcLfjOWPkaFOpz4YdkmHT7EctVb8UVgbMqT4x8Cpni+W1Vh+TwfDvdZFLwzQKUDrH+Y NhyBE4PF9RkLbAd2Itdp9LSwa42og4BGbOsXbRzOcpicsHpCyNKErYlHqfyGlMuGRvN5 pWhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796529246; x=1797134046; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=C4KStiHTQ2qg/vGHdpfA48kZ7RveZ7zTCwE8DfhGNGU=; b=lmkBHbGA/VDG5r4Fi1ubGHopH3GFqmdrtxo1BpFHxoe5yFcBWB0Toc1M5Iu3QHeoMl df89Fr/FDMHuRlQN38MDZaa3l9OWj9rJkzgIS1N3sAT0MfBDRkq1Qsg6fDS/vz/DMeeZ jwYTROcpwc4G26nmTdxFukm6o2OmhNIchpHuWJed7jb2cRLGV2NlPCRfWpXtIzvPn1mv e1NmahSiqm9oOkFQih7QZg/K0C0OIqGj1AhioyKiAtvIICsBuPJmStAe9BormluqXsxa HXeoo3gi7oFMHvfGbNIU6sKgUCWWDw9DfHzY1IKBgUBn/TIwJeK2eMqWzQBfqhEwqQ7p NpqA== X-Forwarded-Encrypted: i=1; AL+hErE+9+Ya6zVRACre1BPUDHK0RKFkB/4NP1qODP4h52A2oNTm4qP7DuxMicT1I75WKEJKZGhi8QzBRXXZsII=@vger.kernel.org X-Gm-Message-State: APuU4Z/++qFCellZxRrmBaCnuymqgKuJBmDOQDTP7us6Gt9RKDi0caH0 8uLe24IdXvBrHHPHj9rL0px0PLGbkQEUe/N7FDyNwKrb3qvFincWjTPlG9Q8PvVnSy6mc4RCpvd azYx08SCiaA== X-Received: from qkbd20.prod.google.com ([2002:a05:620a:31f4:b0:93f:2a4f:d0f6]) (user=willemb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:620a:2b9a:b0:945:d7a8:c5f4 with SMTP id af79cd13be357-94a82f21aa8mr977523585a.62.1796529245277; Sat, 05 Dec 2026 19:54:05 -0800 (PST) Date: Sat, 05 Dec 2026 22:54:04 -0500 In-Reply-To: <20261128165206.3248835-1-julius@bairaktaris.de> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261128165206.3248835-1-julius@bairaktaris.de> Message-ID: Subject: Re: [PATCH net 0/6] net: dsa: offload_fwd_mark on unbridged ports, bridge numbers across switches From: willemb@google.com To: Julius Bairaktaris , Andrew Lunn , Vladimir Oltean , netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , Simon Horman , "=?UTF-8?B?QWx2aW4gxaBpcHJhZ2E=?=" , Linus Walleij , Florian Fainelli , Pawel Dembicki , Tobias Waldekranz , Daniel Golle , Russell King , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8"; format=flowed; delsp=yes Julius Bairaktaris wrote: > Patches 1-3 are about a frame with offload_fwd_mark that reaches the > xmit of a port which is not in a bridge. Patches 4-6 are about bridge > numbers, which DSA hands out across all trees. > 1-2. vsc73xx-8021q and sja1105: a frame received on a bridged port keeps > offload_fwd_mark through a tc mirred redirect or mirror, or an nft > netdev fwd or dup, to a standalone port of the same switch, and the > tagger calls br_vlan_enabled() on the standalone port's bridge, which is > NULL. > - Trigger: a local administrator (CAP_NET_ADMIN) adds such a redirect; > then every frame that a remote host sends to the bridged port and that > the rule matches oopses the kernel in softirq. Less often, a port > leaving its bridge while a frame the bridge marked is queued for it. > - Reachability: vsc73xx-8021q or sja1105/sja1110 with > CONFIG_BRIDGE_VLAN_FILTERING=y. > - Impact: kernel oops (NULL pointer dereference); with the race, also a > read of a freed struct dsa_bridge. > - CVSS 3.1: 4.4 AV:L/AC:L/PR:H/UI:N/S:U/C:N/I:N/A:H (the redirect). > - Workaround: no redirect, mirror or netdev fwd from a bridged port to a > standalone port of the same switch; nothing short of the fix closes > the race. > - Patch 1 frees struct dsa_bridge after an RCU grace period and reads > dp->bridge once wherever the datapath reads it; patch 2 makes the two > taggers send such a frame in the port's standalone VLAN. > 3. tag_dsa: the same redirect makes mv88e6xxx's tagger send the frame as > FORWARD on behalf of bridge 0, i.e. from switch device dst->last_switch, > port 0, instead of FROM_CPU to the port. > - Trigger, reachability (mv88e6xxx with dsa or edsa tagging) and > workaround as for 1-2; impact: the frame goes where the switch sends a > FORWARD frame of that device instead of out of the port; no crash. > - CVSS 3.1: 2.3 AV:L/AC:L/PR:H/UI:N/S:U/C:N/I:L/A:N. > 4. A switch gets a bridge number above its own max_num_bridges when > another switch, with a larger limit, numbered the bridge first: an > mv88e6xxx (up to 31) or mxl862xx (48) tree beside a sja1105 or vsc73xx > tree (7) and eight or more offloaded bridges give the tag_8021q switch > bridge 9 in the VLAN of bridge 1, so two bridges share a broadcast domain > in that switch. > 5. On 32-bit, an mxl862xx switch can take bridge number 32, past the end > of the one unsigned long that tracks them, and set_bit() writes past it. > 6. A bridge spanning two trees loses its number when its last port in one > tree leaves, while the other tree still uses it; the next bridge then > gets the same number, with the same sharing as in 4. > - Trigger (4-6): a local administrator creating bridges with ports of > those switches; reachability: the switch combinations named; impact: > frames of one bridge reach the ports of another (4, 6), memory > corruption of the adjacent variable (5). > - CVSS 3.1: 3.4 AV:L/AC:L/PR:H/UI:N/S:U/C:L/I:L/A:N (4, 6); > 4.4 AV:L/AC:L/PR:H/UI:N/S:U/C:N/I:N/A:H (5). > - Workaround: fewer offloaded bridges than the smallest limit (4, 5); > do not remove the last port of one tree from a bridge that spans two > (6). > All six were found by an LLM review (Claude). 1-4 and 6 were reproduced > in QEMU (x86_64, KASAN and lockdep) with dsa_loop given the tag_8021q > ops, a second switch in a second tree and per-switch bridge limits (a > test-only change, not part of this series), on veth conduits, one run > each: > - redirect: tc ingress matchall mirred redirect from a port of a > vsc73xx-8021q bridge to a standalone port, one frame sent in the > bridge's tag_8021q VLAN: on net 28a371228 "Oops: general protection > fault ... KASAN: null-ptr-deref" in br_vlan_enabled() from > vsc73xx_xmit() and tcf_mirred_act(); with the series the frame leaves > in the standalone port's VLAN; > - leave: two ports with a 400 ms netem delay leave the bridge with 20 > broadcasts queued: on net "BUG: KASAN: null-ptr-deref in > br_vlan_enabled"; with the series 18 > of the 20 leave in a standalone VLAN and dmesg is clean; > - edsa, the same redirect: on net the frame leaves with a FORWARD tag > (first tag byte 0xc0); with the series FROM_CPU to the port (0x40, > port 2); > - two trees with limits 31 and 1: on net the second is handed bridge > number 2; with the series its port is bridged in software with "Range > of offloadable bridges exceeded"; > - a bridge with one port in each tree, the port of the first tree taken > out, a new bridge created there: on net the new bridge gets the number > the second tree still uses; with the series the next free one. > 5 is from reading: dsa_loop has too few ports to reach 32 bridges. > I used Claude (Anthropic) to help write these patches. > Julius Bairaktaris (6): > net: dsa: free struct dsa_bridge after an RCU grace period > net: dsa: tag_sja1105, tag_vsc73xx_8021q: read the bridge once in xmit > net: dsa: tag_dsa: send a marked frame of an unbridged port from the > CPU > net: dsa: do not hand a switch a bridge number above its limit > net: dsa: do not take a bridge number past the end of the bitmap > net: dsa: keep a bridge number while another tree uses it > include/net/dsa.h | 14 ++++++++++++-- > net/dsa/dsa.c | 17 +++++++++++++---- > net/dsa/port.c | 21 +++++++++++++++++---- > net/dsa/tag.h | 4 ++-- > net/dsa/tag_8021q.c | 6 ++++-- > net/dsa/tag_dsa.c | 14 ++++++++------ > net/dsa/tag_sja1105.c | 21 ++++++++++++++------- > net/dsa/tag_vsc73xx_8021q.c | 14 +++++++++----- > 8 files changed, 79 insertions(+), 32 deletions(-) > base-commit: 28a371228d4eb4857cc31eeb1a0d7d01e9c3ea2f > -- > 2.53.0 Patch 1/6 (RCU lifetime for struct dsa_bridge) and Patch 5/6 (bitmap upper-bound check before set_bit()) are sound on their own, and Patch 4/6 addresses a real cross-switch limit bug. However, the series is NOT ready to merge: independent verification against netdev-net/main confirms two non-preexisting High bugs (Patch 3/6 leaves non-PVT mv88e6xxx chips broken; Patch 6/6 leaves cross-tree bridge-number reuse broken whenever a tree with max_num_bridges == 0 precedes another tree in dsa_tree_list, and the same dsa_bridge_num_find() defect also breaks dsa_bridge_num_get()/Patch 4/6), two non-preexisting Medium bugs (Patch 2/6 bypasses SJA1105/SJA1110 link-local/PTP handling on !bridge; Patches 2-3 do not address RX offload_fwd_mark leaking across tc/nft redirects onto bridged ports), an inaccurate Fixes trailer on Patch 6/6, and bundling of two unrelated DSA topics targeting post-rc4 net.