All of lore.kernel.org
 help / color / mirror / Atom feed
From: willemb@google.com
To: Julius Bairaktaris <julius@bairaktaris.de>,
	Andrew Lunn <andrew@lunn.ch>,
	 Vladimir Oltean <olteanv@gmail.com>,
	netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@kernel.org>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Willem de Bruijn" <willemb@google.com>,
	"Simon Horman" <horms@kernel.org>,
	"Alvin Šipraga" <alvin.sipraga@analog.com>,
	"Linus Walleij" <linusw@kernel.org>,
	"Florian Fainelli" <florian.fainelli@broadcom.com>,
	"Pawel Dembicki" <paweldembicki@gmail.com>,
	"Tobias Waldekranz" <tobias@waldekranz.com>,
	"Daniel Golle" <daniel@makrotopia.org>,
	"Russell King" <linux@armlinux.org.uk>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net 0/6] net: dsa: offload_fwd_mark on unbridged ports, bridge numbers across switches
Date: Sat, 05 Dec 2026 22:54:04 -0500	[thread overview]
Message-ID: <willemb.2b0286434221c@google.com> (raw)
In-Reply-To: <20261128165206.3248835-1-julius@bairaktaris.de>

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.


      parent reply	other threads:[~2026-12-06  3:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-28 16:51 [PATCH net 0/6] net: dsa: offload_fwd_mark on unbridged ports, bridge numbers across switches Julius Bairaktaris
2026-11-28 16:52 ` [PATCH net 1/6] net: dsa: free struct dsa_bridge after an RCU grace period Julius Bairaktaris
2026-11-28 16:52 ` [PATCH net 2/6] net: dsa: tag_sja1105, tag_vsc73xx_8021q: read the bridge once in xmit Julius Bairaktaris
2026-12-06  3:54   ` willemb
2026-11-28 16:52 ` [PATCH net 3/6] net: dsa: tag_dsa: send a marked frame of an unbridged port from the CPU Julius Bairaktaris
2026-12-06  3:55   ` willemb
2026-11-28 16:52 ` [PATCH net 4/6] net: dsa: do not hand a switch a bridge number above its limit Julius Bairaktaris
2026-12-06  3:55   ` willemb
2026-11-28 16:52 ` [PATCH net 5/6] net: dsa: do not take a bridge number past the end of the bitmap Julius Bairaktaris
2026-11-28 16:52 ` [PATCH net 6/6] net: dsa: keep a bridge number while another tree uses it Julius Bairaktaris
2026-12-06  3:57   ` willemb
2026-12-06  3:54 ` willemb [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=willemb.2b0286434221c@google.com \
    --to=willemb@google.com \
    --cc=alvin.sipraga@analog.com \
    --cc=andrew@lunn.ch \
    --cc=daniel@makrotopia.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=florian.fainelli@broadcom.com \
    --cc=horms@kernel.org \
    --cc=julius@bairaktaris.de \
    --cc=kuba@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=paweldembicki@gmail.com \
    --cc=tobias@waldekranz.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.