Commit 049107c1 authored by Duoming Zhou's avatar Duoming Zhou Committed by Xiongfeng Wang
Browse files

watchdog: cpu5wdt.c: Fix use-after-free bug caused by cpu5wdt_trigger

mainline inclusion
from mainline-v6.10-rc1
commit 573601521277119f2e2ba5f28ae6e87fc594f4d4
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IA7D7P
CVE: CVE-2024-38630

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=573601521277119f2e2ba5f28ae6e87fc594f4d4



--------------------------------

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: e09d9c3e ("watchdog: cpu5wdt.c: add missing del_timer call")
Signed-off-by: default avatarDuoming Zhou <duoming@zju.edu.cn>
Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20240324140444.119584-1-duoming@zju.edu.cn


Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarWim Van Sebroeck <wim@linux-watchdog.org>
conflict:
	drivers/watchdog/cpu5wdt.c
[wxf: use del_timer_sync() rather than timer_shutdown_sync(), because
the later function is not introduced.]
Signed-off-by: default avatarXiongfeng Wang <wangxiongfeng2@huawei.com>
parent 626a20fc
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment