Linux s390 Architecture development
 help / color / mirror / Atom feed
* [PATCH net v3 0/2] s390/ctcm: Fix timer corruption and use-after-free
@ 2026-09-22 10:19 Nagamani PV
  2026-09-22 10:19 ` [PATCH net v3 1/2] s390/ctcm: Fix timer corruption in fsm_addtimer() Nagamani PV
  2026-09-22 10:19 ` [PATCH net v3 2/2] s390/ctcm: Fix use-after-free in channel_remove() Nagamani PV
  0 siblings, 2 replies; 7+ messages in thread
From: Nagamani PV @ 2026-09-22 10:19 UTC (permalink / raw)
  To: andrew+netdev, davem, edumazet, kuba, pabeni
  Cc: wintera, aswin, hca, gor, agordeev, borntraeger, svens, kees,
	linux-s390, netdev, Nagamani PV

Fix two timer 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() - timer_delete()
returns before any running callback finishes, leaving a window where
the timer callback can access freed memory. For MPC channels,
ch_tasklet and ch_disc_tasklet are killed first so they cannot access
freed memory or re-arm sweep_timer; sweep_timer is then shut down with
timer_shutdown_sync() because its callback can re-arm ch->timer; only
then is ch->timer stopped with timer_delete_sync().

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: stable@vger.kernel.org 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 | 15 +++++++--------
 drivers/s390/net/fsm.c       |  9 ++-------
 2 files changed, 9 insertions(+), 15 deletions(-)

-- 
2.53.0


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

end of thread, other threads:[~2026-09-30  7:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-22 10:19 [PATCH net v3 0/2] s390/ctcm: Fix timer corruption and use-after-free Nagamani PV
2026-09-22 10:19 ` [PATCH net v3 1/2] s390/ctcm: Fix timer corruption in fsm_addtimer() Nagamani PV
2026-09-23 10:19   ` sashiko-bot
2026-09-22 10:19 ` [PATCH net v3 2/2] s390/ctcm: Fix use-after-free in channel_remove() Nagamani PV
2026-09-23 10:19   ` sashiko-bot
2026-09-28 23:34   ` Jakub Kicinski
2026-09-30  7:29     ` Nagamani PV

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox