netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] atm: idt77252: fix use-after-free bugs caused by tst_timer
@ 2022-08-05  7:00 Duoming Zhou
  2022-08-09  4:00 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Duoming Zhou @ 2022-08-05  7:00 UTC (permalink / raw)
  To: linux-atm-general; +Cc: 3chas3, netdev, linux-kernel, Duoming Zhou

There are use-after-free bugs caused by tst_timer. The root cause
is that there are no functions to stop tst_timer in idt77252_exit().
One of the possible race conditions is shown below:

    (thread 1)          |        (thread 2)
                        |  idt77252_init_one
                        |    init_card
                        |      fill_tst
                        |        mod_timer(&card->tst_timer, ...)
idt77252_exit           |  (wait a time)
                        |  tst_timer
                        |
                        |    ...
  kfree(card) // FREE   |
                        |    card->soft_tst[e] // USE

The idt77252_dev is deallocated in idt77252_exit() and used in
timer handler.

This patch adds del_timer_sync() in idt77252_exit() in order that
the timer handler could be stopped before the idt77252_dev is
deallocated.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
---
 drivers/atm/idt77252.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
index 81ce81a75fc..681cb378679 100644
--- a/drivers/atm/idt77252.c
+++ b/drivers/atm/idt77252.c
@@ -3752,6 +3752,7 @@ static void __exit idt77252_exit(void)
 		card = idt77252_chain;
 		dev = card->atmdev;
 		idt77252_chain = card->next;
+		del_timer_sync(&card->tst_timer);
 
 		if (dev->phy->stop)
 			dev->phy->stop(dev);
-- 
2.17.1


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

* Re: [PATCH] atm: idt77252: fix use-after-free bugs caused by tst_timer
  2022-08-05  7:00 [PATCH] atm: idt77252: fix use-after-free bugs caused by tst_timer Duoming Zhou
@ 2022-08-09  4:00 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-08-09  4:00 UTC (permalink / raw)
  To: Duoming Zhou; +Cc: linux-atm-general, 3chas3, netdev, linux-kernel

Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Fri,  5 Aug 2022 15:00:08 +0800 you wrote:
> There are use-after-free bugs caused by tst_timer. The root cause
> is that there are no functions to stop tst_timer in idt77252_exit().
> One of the possible race conditions is shown below:
> 
>     (thread 1)          |        (thread 2)
>                         |  idt77252_init_one
>                         |    init_card
>                         |      fill_tst
>                         |        mod_timer(&card->tst_timer, ...)
> idt77252_exit           |  (wait a time)
>                         |  tst_timer
>                         |
>                         |    ...
>   kfree(card) // FREE   |
>                         |    card->soft_tst[e] // USE
> 
> [...]

Here is the summary with links:
  - atm: idt77252: fix use-after-free bugs caused by tst_timer
    https://git.kernel.org/netdev/net/c/3f4093e2bf46

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2022-08-09  4:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-05  7:00 [PATCH] atm: idt77252: fix use-after-free bugs caused by tst_timer Duoming Zhou
2022-08-09  4:00 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).