Skip to content

net/stmmac: Fix panic during interface shutdown & apply STMMAC_DOWN flag

Jakub Raczynski linux-arm-kernel lkml netdev 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest2 patches 1 replyIn review
  2. v22 patches 3 repliesSuperseded

Changes in v3 from the cover letter

- Discard almost all changes from v2.
This was a mistake as napi_disable() does ensure napi_synchronize() and it didn't fix anything in the end.
- Return STMMAC_DOWN flag set/clear
- Create new function that executes synchronize_rcu() and call it from proper places
- Remove synchronize_rcu() from stmmac_disable_all_queues()
- Remove barren stmmac_disable_all_queues() and replace it with __stmmac_disable_all_queues()
- Fix memory leak in STMMAC_DOWN handling in modified XDP paths

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2net/stmmac: Check for STMMAC_DOWN flag in all XDP pathsdrivers/net/ethernet/stmicro/stmmac/stmmac_main.c+10 -21 reply
2/2net/stmmac: Fix free-after-use panic when interface goes does with XDPdrivers/net/ethernet/stmicro/stmmac/stmmac_main.c+21 -70 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH net v3 0/2] net/stmmac: Fix panic during interface shutdown & apply STMMAC_DOWN flag

When testing interface shutdown during XDP operation using stmmac driver, we have encountered kernel panics, either poison overwritten or wrong memory access, caused by XDP processing data after shutting down NAPI.

To fix this problem:
- Add STMMAC_DOWN handling to all XDP paths
- Change location of synchronize_rcu() to proper place
- Apply STMMAC_DOWN flag on interface open()/release().
This flag is used for XDP only and does improve handling in edge cases

Proper order of ensuring proper XDP shutdown is already present in functions from stmmac_xdp.c during xdp_disable_pool(), since XDP can still have data with NAPI disabled, as disabling NAPI does not ensure XDP finish. synchronize_rcu() must be executed after IRQ's & DMA channels are disabled to flush data.

---
Changes in v3:
- Discard almost all changes from v2.
This was a mistake as napi_disable() does ensure napi_synchronize() and it didn't fix anything in the end.
- Return STMMAC_DOWN flag set/clear
- Create new function that executes synchronize_rcu() and call it from proper places
- Remove synchronize_rcu() from stmmac_disable_all_queues()
- Remove barren stmmac_disable_all_queues() and replace it with __stmmac_disable_all_queues()
- Fix memory leak in STMMAC_DOWN handling in modified XDP paths

Changes in v2:
- Split patch into two: one for XDP paths and second for general fix
- Change commit messages & title
- Fix all cases of NAPI release, not only XDP, via modyfying stmmac_disable_all_queues() instead of separate later call
- Drop setting/clearing of STMMAC_DOWN flag in release()/open()

Link to v2:
https://lore.kernel.org/all/[email protected]
Link to v1:
https://lore.kernel.org/all/[email protected]

Jakub Raczynski (2):
net/stmmac: Check for STMMAC_DOWN flag in all XDP paths net/stmmac: Fix free-after-use panic when interface goes does with XDP

 .../net/ethernet/stmicro/stmmac/stmmac_main.c | 40 ++++++++++++++-----
 1 file changed, 31 insertions(+), 9 deletions(-)
Signature · 1 line
2.34.1