net: dsa: qca8k: fix concurrent register and MIB autocast access
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest3 patches 2 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | net: dsa: qca8k: let regmap serialize register accessdrivers/ | +0 | 0 replies | |
| 2/3 | net: dsa: qca8k: drop MIB autocast frames once the request is overdrivers/ drivers/ | +23 | 2 replies | |
| 3/3 | net: dsa: qca8k: check the length of MIB autocast framesdrivers/ | +11 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH net 0/3] net: dsa: qca8k: fix concurrent register and MIB autocast access
The netdev AI review of my net-next MIB statistics series [1] found three bugs that are already in released kernels. They do not depend on that series, so here they are for net:
1. Since the conversion to the regmap read/write API, the regmap uses a shared work_buf but is created with .disable_locking. phylink's resolve work and the LED callbacks access registers outside rtnl, so concurrent users can swap or corrupt register and value.
2. An ethtool MIB request over Ethernet (autocast) that times out leaves the caller's buffer published. Late frames then write into the buffer after ethtool has freed it, and extra frames underflow the frame counter.
3. The autocast handler reads up to 164 bytes of counters without checking the frame length.
The MIB statistics series will be rebased on these once net-next reopens.
Testing: on a GL-B3000 (IPQ5018 + QCA8337, CPU on port 0) with the qca tagger, backported to OpenWrt's 6.18 kernel with PROVE_LOCKING. That tree also carries the MIB statistics series, so a work polls the MIB every 3 s next to ethtool -S. In four minutes under about 50 Mbit/s of routed traffic, 938 MIB frames arrived after their request had already returned, and all were dropped. Frames made artificially short were left uncounted, and the requests fell back to register reads. The ethtool and netdev counters stayed monotonic, and there were no lockdep, refcount or other warnings.
[1] https://lore.kernel.org/netdev/[email protected]/
Stanislaw Pal (3):
net: dsa: qca8k: let regmap serialize register access
net: dsa: qca8k: drop MIB autocast frames once the request is over
net: dsa: qca8k: check the length of MIB autocast frames
drivers/net/dsa/qca/qca8k-8xxx.c | 34 ++++++++++++++++++++++++++++++-- drivers/net/dsa/qca/qca8k.h | 3 ++- 2 files changed, 34 insertions(+), 3 deletions(-)
Signature · 1 line
2.43.0