public inbox for linux-serial@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tty: ipwireless: Fix use-after-free in tasklet during device removal
@ 2026-02-08  6:25 Duoming Zhou
  2026-02-08  6:38 ` Greg KH
  0 siblings, 1 reply; 14+ messages in thread
From: Duoming Zhou @ 2026-02-08  6:25 UTC (permalink / raw)
  To: linux-serial
  Cc: linux-kernel, jikos, dsterba, gregkh, jirislaby, kuba,
	alexander.deucher, akpm, pkshih, tglx, mingo, Duoming Zhou

When IPWireless PCMCIA card is being detached, the ipw_hardware is
deallocated in ipwireless_hardware_free(). However, the hw->tasklet may
still be running or pending, leading to use-after-free bugs when the
already freed ipw_hardware is accessed again in ipwireless_do_tasklet().

One race condition scenario is as follows:

CPU 0 (cleanup)               | CPU 1 (interrupt)
ipwireless_hardware_free()    | ipwireless_interrupt()
  ipwireless_stop_interrupts()|   ipwireless_handle_v1_interrupt()
    do_close_hardware()       |     tasklet_schedule()
      synchronize_irq()       |
  kfree(hw) //FREE            | ipwireless_do_tasklet() //handler
                              |   hw = from_tasklet() //USE
                              |   hw-> //USE

Fix this by ensuring hw->tasklet is properly canceled before ipw_hardware
is released. Add tasklet_kill() in ipwireless_stop_interrupts() to
synchronize with any pending or running tasklet. Since do_close_hardware()
could prevent further interrupts, place tasklet_kill() after it to avoid
the tasklet being rescheduled by ipwireless_interrupt().

Fixes: 099dc4fb6265 ("ipwireless: driver for PC Card 3G/UMTS modem")
Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
---
 drivers/tty/ipwireless/hardware.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/tty/ipwireless/hardware.c b/drivers/tty/ipwireless/hardware.c
index e18848267be..c736cba751f 100644
--- a/drivers/tty/ipwireless/hardware.c
+++ b/drivers/tty/ipwireless/hardware.c
@@ -1725,6 +1725,7 @@ void ipwireless_stop_interrupts(struct ipw_hardware *hw)
 
 		/* Prevent the hardware from sending any more interrupts */
 		do_close_hardware(hw);
+		tasklet_kill(&hw->tasklet);
 	}
 }
 
-- 
2.34.1


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

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

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-08  6:25 [PATCH] tty: ipwireless: Fix use-after-free in tasklet during device removal Duoming Zhou
2026-02-08  6:38 ` Greg KH
2026-02-08 10:28   ` duoming
2026-02-08 11:00     ` Greg KH
2026-02-08 13:57       ` duoming
2026-02-08 14:34         ` Greg KH
2026-02-08 14:53           ` duoming
2026-02-08 14:58             ` Greg KH
2026-02-08 17:25       ` Jiri Kosina
2026-02-09 10:21         ` David Sterba
2026-02-17  8:03           ` Jiri Slaby
2026-02-18 15:23             ` David Sterba
2026-03-09 11:18               ` Qingfang Deng
2026-03-09 11:25                 ` Greg KH

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