Skip to content

s390/ctcm: Fix timer corruption and use-after-free

Nagamani PV linux-s390 netdev stable 4 versions – Applied

Status from this message: This series was applied to netdev/net-next.git (main)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest2 patches 6 repliesApplied 2/2
  2. v32 patches 2 repliesSuperseded
  3. v22 patches 2 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v12 patches2 repliesSuperseded

Changes in v4 from the cover letter

- Patch 2: shut down timers before tasklet_kill() rather than after, shutting down sweep_timer before ch->timer.
- Patch 2: use timer_shutdown_sync() for ch->timer on both MPC and non-MPC paths.
- Patch 2: name prerequisite by commit title and add structured stable tag dependency (Jakub Kicinski).
- Patch 2: code changed; Reviewed-by and Tested-by dropped.

Patches in v4 All 2 applied

#Subject and filesSizeRepliesApplied
1/2s390/ctcm: Fix timer corruption in fsm_addtimer()drivers/s390/net/fsm.c+2 -71 replyApplied
2/2s390/ctcm: Fix use-after-free in channel_remove()drivers/s390/net/ctcm_main.c+7 -73 repliesApplied

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchAswin KaruvallySimon Horman
1/2R-b T-b R-b
2/2R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH net v4 0/2] s390/ctcm: Fix timer corruption and use-after-free

Fix two bugs in drivers/s390/net/fsm.c and drivers/s390/net/ctcm_main.c found by Sashiko AI code review.

Patch 1 fixes timer list corruption when fsm_addtimer() is called on an already-pending timer - timer_setup() re-initializes the timer list_head while it is still enqueued in the wheel.

Patch 2 fixes a use-after-free in channel_remove(). For MPC channels the teardown has a circular dependency: the ch->timer callback can schedule ch_disc_tasklet via mpc_action_go_inop(), ch_tasklet can re-arm sweep_timer, and sweep_timer's callback re-arms ch->timer. Fix by shutting down both MPC timers with timer_shutdown_sync() first (sweep_timer before ch->timer), then killing both tasklets. This breaks all three re-arm paths before freeing channel resources.

Changes in v4:
- Patch 2: shut down timers before tasklet_kill() rather than after, shutting down sweep_timer before ch->timer.
- Patch 2: use timer_shutdown_sync() for ch->timer on both MPC and non-MPC paths.
- Patch 2: name prerequisite by commit title and add structured stable tag dependency (Jakub Kicinski).
- Patch 2: code changed; Reviewed-by and Tested-by dropped.

Changes in v3:
- Patch 2: fix MPC tasklet/timer re-arm UAF identified by Sashiko:
kill ch_tasklet and ch_disc_tasklet before stopping the timers, then shut down sweep_timer before deleting ch->timer; move kfree(discontact_th) into the MPC teardown block.
- Patch 2: code changed; Reviewed-by and Tested-by dropped.

Note: two pre-existing UAFs in ctcm_free_netdevice() (grp->timer, priv->restart_timer) and a NULL deref in ctcmpc_chx_txdone() are confirmed but out of scope for this series; follow-up patch planned.

Changes in v2:
- Patch 1: fix function name ctcm_send_sweep() -> ctcmpc_send_sweep_req() in the commit message (Sashiko netdev-bot)
- Patch 1: call mod_timer() then return 0 explicitly, preserving the "Always returns 0" contract documented in fsm.h (Sashiko netdev-bot)
- Patch 2: add Fixes: and Cc: [email protected] tags (Sashiko netdev-bot)

Nagamani PV (2):
s390/ctcm: Fix timer corruption in fsm_addtimer() s390/ctcm: Fix use-after-free in channel_remove()

 drivers/s390/net/ctcm_main.c | 14 +++++++-------
 drivers/s390/net/fsm.c       |  9 ++-------
 2 files changed, 9 insertions(+), 14 deletions(-)
Signature · 1 line
2.53.0