watchdog: cpu5wdt.c: Fix use-after-free bug caused by cpu5wdt_trigger
authorDuoming Zhou <duoming@zju.edu.cn>
Sun, 24 Mar 2024 14:04:44 +0000 (22:04 +0800)
committerWim Van Sebroeck <wim@linux-watchdog.org>
Sat, 4 May 2024 10:50:40 +0000 (12:50 +0200)
commit573601521277119f2e2ba5f28ae6e87fc594f4d4
treeecf4cdc2a31d15366de1abe74f6fdffd2749835c
parent1f6602c8ed1eccac4fa83e338d02aafe3a0e2c0a
watchdog: cpu5wdt.c: Fix use-after-free bug caused by cpu5wdt_trigger

When the cpu5wdt module is removing, the origin code uses del_timer() to
de-activate the timer. If the timer handler is running, del_timer() could
not stop it and will return directly. If the port region is released by
release_region() and then the timer handler cpu5wdt_trigger() calls outb()
to write into the region that is released, the use-after-free bug will
happen.

Change del_timer() to timer_shutdown_sync() in order that the timer handler
could be finished before the port region is released.

Fixes: e09d9c3e9f85 ("watchdog: cpu5wdt.c: add missing del_timer call")
Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20240324140444.119584-1-duoming@zju.edu.cn
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
drivers/watchdog/cpu5wdt.c