Skip to contentSkip to conversation

wifi: ath9k: delete channel-context timers on deinit

PATCH Applied Rosen Penev 3 participants 4 messages Sep 11 – Oct 5 Qualcomm Atheros ATH9K wireless driver

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 wifi: ath9k: delete channel-context timers on deinit

ath9k_deinit_channel_context() cancels chanctx_work but does not delete the offchannel and sched timers set up by ath9k_init_channel_context(). If either timer fires after deinit (e.g. during driver unload or suspend), it accesses sc->sc_ah which may already be freed by ath9k_hw_deinit(), causing a use-after-free.

Delete both timers with timer_shutdown_sync() before cancelling the work item.

Assisted-by LLM

---
v2: use timer_shutdown_sync()

 drivers/net/wireless/ath/ath9k/channel.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/wireless/ath/ath9k/channel.c +2 -0
index 8b27d8cc086a..cfb1c90eb4b6 100644
@@ -1363,6 +1363,8 @@ void ath9k_init_channel_context(struct ath_softc *sc)
 
 void ath9k_deinit_channel_context(struct ath_softc *sc)
 {
+	timer_shutdown_sync(&sc->sched.timer);
+	timer_shutdown_sync(&sc->offchannel.timer);
 	cancel_work_sync(&sc->chanctx_work);
 }
 
Signature · 1 line
2.55.0
maintainer Acked-by on v2 1/1
#1 lore raw
Quoted 11 lines · Rosen Penev

ath9k_deinit_channel_context() cancels chanctx_work but does not delete the offchannel and sched timers set up by ath9k_init_channel_context(). If either timer fires after deinit (e.g. during driver unload or suspend), it accesses sc->sc_ah which may already be freed by ath9k_hw_deinit(), causing a use-after-free.

Delete both timers with timer_shutdown_sync() before cancelling the work item.

Assisted-by LLM
#2 lore raw
Quoted 8 lines · Toke Høiland-Jørgensen
Quoted 6 lines · Rosen Penev

ath9k_deinit_channel_context() cancels chanctx_work but does not delete the offchannel and sched timers set up by ath9k_init_channel_context(). If either timer fires after deinit (e.g. during driver unload or suspend), it accesses sc->sc_ah which may already be freed by ath9k_hw_deinit(), causing a use-after-free.

Quoted 7 lines
Quoted 5 lines

Delete both timers with timer_shutdown_sync() before cancelling the work item.

Assisted-by LLM

I'm picking this up now. Will add the following suggested by my review agent:

Fixes 705d0bf83dbe ("ath9k: Add a routine for initializing channel contexts")
Applied
#3 lore raw
In reply to Rosen Penev
Quoted 10 lines · Rosen Penev

ath9k_deinit_channel_context() cancels chanctx_work but does not delete the offchannel and sched timers set up by ath9k_init_channel_context(). If either timer fires after deinit (e.g. during driver unload or suspend), it accesses sc->sc_ah which may already be freed by ath9k_hw_deinit(), causing a use-after-free.

Delete both timers with timer_shutdown_sync() before cancelling the work item.

[...]

Applied, thanks!

[1/1] wifi: ath9k: delete channel-context timers on deinit

      commit: 81394dfb9a7905472957628b560ae894eae3a30f

Best regards,

Signature · 1 line
Jeff Johnson <[email protected]>