All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net 0/6] net: dsa: offload_fwd_mark on unbridged ports, bridge numbers across switches
@ 2026-11-28 16:51 Julius Bairaktaris
  2026-11-28 16:52 ` [PATCH net 1/6] net: dsa: free struct dsa_bridge after an RCU grace period Julius Bairaktaris
                   ` (6 more replies)
  0 siblings, 7 replies; 12+ messages in thread
From: Julius Bairaktaris @ 2026-11-28 16:51 UTC (permalink / raw)
  To: Andrew Lunn, Vladimir Oltean, netdev
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Willem de Bruijn, Simon Horman, Alvin Šipraga, Linus Walleij,
	Florian Fainelli, Pawel Dembicki, Tobias Waldekranz, Daniel Golle,
	Russell King, linux-kernel

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


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-12-06  3:57 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH net 0/6] net: dsa: offload_fwd_mark on unbridged ports, bridge numbers across switches willemb

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.