]> git.baikalelectronics.ru Git - kernel.git/commit
atm: idt77252: fix use-after-free bugs caused by tst_timer
authorDuoming Zhou <duoming@zju.edu.cn>
Fri, 5 Aug 2022 07:00:08 +0000 (15:00 +0800)
committerJakub Kicinski <kuba@kernel.org>
Tue, 9 Aug 2022 03:51:59 +0000 (20:51 -0700)
commit0cbf0d0f61690e65c37f3061067bffd6bcb4339b
treeb8401e7acce01f755568d76eb4242bb6c9fed524
parentc255be0c5f5f78d844a74c7d1cb5bb24c95c2a8a
atm: idt77252: fix use-after-free bugs caused by tst_timer

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>
Link: https://lore.kernel.org/r/20220805070008.18007-1-duoming@zju.edu.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/atm/idt77252.c