mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH ath-next] ath9k: delete channel-context timers on deinit
@ 2026-09-04 21:22 Rosen Penev
  2026-09-11 10:36 ` Toke Høiland-Jørgensen
  2026-09-11 16:56 ` Jeff Johnson
  0 siblings, 2 replies; 3+ messages in thread
From: Rosen Penev @ 2026-09-04 21:22 UTC (permalink / raw)
  To: linux-wireless; +Cc: Toke Høiland-Jørgensen, open list

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_delete_sync() before cancelling the work
item.

Assisted-by: opencode:big-pickle
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/net/wireless/ath/ath9k/channel.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/wireless/ath/ath9k/channel.c b/drivers/net/wireless/ath/ath9k/channel.c
index 8b27d8cc086a..92241c24a0a4 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -1363,6 +1363,8 @@ void ath9k_init_channel_context(struct ath_softc *sc)
 
 void ath9k_deinit_channel_context(struct ath_softc *sc)
 {
+	timer_delete_sync(&sc->sched.timer);
+	timer_delete_sync(&sc->offchannel.timer);
 	cancel_work_sync(&sc->chanctx_work);
 }
 
-- 
2.55.0


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

* Re: [PATCH ath-next] ath9k: delete channel-context timers on deinit
  2026-09-04 21:22 [PATCH ath-next] ath9k: delete channel-context timers on deinit Rosen Penev
@ 2026-09-11 10:36 ` Toke Høiland-Jørgensen
  2026-09-11 16:56 ` Jeff Johnson
  1 sibling, 0 replies; 3+ messages in thread
From: Toke Høiland-Jørgensen @ 2026-09-11 10:36 UTC (permalink / raw)
  To: Rosen Penev, linux-wireless; +Cc: open list

Rosen Penev <rosenp@gmail.com> writes:

> 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_delete_sync() before cancelling the work
> item.

From the documentation of that function:

 * This function cannot guarantee that the timer is not rearmed again by
 * some concurrent or preempting code, right after it dropped the base
 * lock. If there is the possibility of a concurrent rearm then the return
 * value of the function is meaningless.
 *
 * If such a guarantee is needed, e.g. for teardown situations then use
 * timer_shutdown_sync() instead.

AFAICT, the timer callbacks can re-arm the timer, so this should be
using timer_shutdown_sync() instead.

-Toke

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

* Re: [PATCH ath-next] ath9k: delete channel-context timers on deinit
  2026-09-04 21:22 [PATCH ath-next] ath9k: delete channel-context timers on deinit Rosen Penev
  2026-09-11 10:36 ` Toke Høiland-Jørgensen
@ 2026-09-11 16:56 ` Jeff Johnson
  1 sibling, 0 replies; 3+ messages in thread
From: Jeff Johnson @ 2026-09-11 16:56 UTC (permalink / raw)
  To: Rosen Penev, linux-wireless; +Cc: Toke Høiland-Jørgensen, open list

On 9/4/2026 2:22 PM, Rosen Penev wrote:
> 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_delete_sync() before cancelling the work
> item.
> 
> Assisted-by: opencode:big-pickle

Current guidance is to just have Assisted-by: LLM
https://docs.kernel.org/process/coding-assistants.html#attribution


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

end of thread, other threads:[~2026-09-11 16:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-04 21:22 [PATCH ath-next] ath9k: delete channel-context timers on deinit Rosen Penev
2026-09-11 10:36 ` Toke Høiland-Jørgensen
2026-09-11 16:56 ` Jeff Johnson

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

all inboxes | Powered by JetHome®