CVE-2024-38630: watchdog: cpu5wdt.c: Fix use-after-free bug caused by cpu5wdt_trigger
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
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.
The Linux kernel CVE team has assigned CVE-2024-38630 to this issue.
Affected and fixed versions
===========================
Issue introduced in 3.8 with commit e09d9c3e9f85 and fixed in 6.6.33 with commit 9b1c063ffc07 Issue introduced in 3.8 with commit e09d9c3e9f85 and fixed in 6.9.4 with commit f19686d61650 Issue introduced in 3.8 with commit e09d9c3e9f85 and fixed in 6.10-rc1 with commit 573601521277
Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community.
Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at
https://cve.org/CVERecord/?id=CVE-2024-38630
will be updated if fixes are backported, please check that for the most up to date information about this issue.
Affected files
==============
The file(s) affected by this issue are:
drivers/watchdog/cpu5wdt.c
Mitigation
==========
The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits:
https://git.kernel.org/stable/c/9b1c063ffc075abf56f63e55d70b9778ff534314 https://git.kernel.org/stable/c/f19686d616500cd0d47b30cee82392b53f7f784a https://git.kernel.org/stable/c/573601521277119f2e2ba5f28ae6e87fc594f4d4
Hi all,
Quoted 20 lines · Greg Kroah-Hartman
Description
===========In the Linux kernel, the following vulnerability has been resolved:
watchdog:
cpu5wdt.c: Fix use-after-free bug caused bycpu5wdt_triggerWhen 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 byrelease_region()and then the timer handlercpu5wdt_trigger()callsoutb()to write into the region that is released, the use-after-free bug will happen.Change
del_timer()totimer_shutdown_sync()in order that the timer handler could be finished before the port region is released.The Linux kernel CVE team has assigned CVE-2024-38630 to this issue.
Quoted 6 lines
Affected and fixed versions
===========================Issue introduced in 3.8 with commit
e09d9c3e9f85and fixed in 6.6.33 with commit9b1c063ffc07Issue introduced in 3.8 with commite09d9c3e9f85and fixed in 6.9.4 with commitf19686d61650Issue introduced in 3.8 with commite09d9c3e9f85and fixed in 6.10-rc1 with commit 573601521277
For the record, this is incorrect. The Fixes tag is misleading. The commit being "fixed" was adding a missing del_timer() call, so the situation was even worst before that, as the race window on module removal was even larger.
The bug is present since kernel v2.5.61 when the cpu5wdt driver was added to the kernel tree.
Also note that the bug was fixed using timer_shutdown_sync(), which is documented as only being needed when the timer can be rearmed by a workqueue or similar scenario, which is not the case here. So I'm reasonably certain that using del_timer_sync() would have been sufficient.
Signature · 2 lines
Jean Delvare SUSE L3 Support
Quoted 30 lines · Jean Delvare
Hi all,
Quoted 20 lines · Greg Kroah-Hartman
Description
===========In the Linux kernel, the following vulnerability has been resolved:
watchdog:
cpu5wdt.c: Fix use-after-free bug caused bycpu5wdt_triggerWhen 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 byrelease_region()and then the timer handlercpu5wdt_trigger()callsoutb()to write into the region that is released, the use-after-free bug will happen.Change
del_timer()totimer_shutdown_sync()in order that the timer handler could be finished before the port region is released.The Linux kernel CVE team has assigned CVE-2024-38630 to this issue.
Quoted 6 lines
Affected and fixed versions
===========================Issue introduced in 3.8 with commit
e09d9c3e9f85and fixed in 6.6.33 with commit9b1c063ffc07Issue introduced in 3.8 with commite09d9c3e9f85and fixed in 6.9.4 with commitf19686d61650Issue introduced in 3.8 with commite09d9c3e9f85and fixed in 6.10-rc1 with commit 573601521277
Quoted 7 lines
For the record, this is incorrect. The Fixes tag is misleading. The commit being "fixed" was adding a missing
del_timer()call, so the situation was even worst before that, as the race window on module removal was even larger.The bug is present since kernel v2.5.61 when the cpu5wdt driver was added to the kernel tree.
So should I change the "vulnerable" commit to be the root of git, commit 1da177e4c3f4 ("Linux-2.6.12-rc2"), instead?
thanks,
greg k-h
Hi Greg,
Quoted 34 lines · Greg Kroah-Hartman
Quoted 33 lines · Jean Delvare
Quoted 20 lines · Greg Kroah-Hartman
Description
===========In the Linux kernel, the following vulnerability has been resolved:
watchdog:
cpu5wdt.c: Fix use-after-free bug caused bycpu5wdt_triggerWhen 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 byrelease_region()and then the timer handlercpu5wdt_trigger()callsoutb()to write into the region that is released, the use-after-free bug will happen.Change
del_timer()totimer_shutdown_sync()in order that the timer handler could be finished before the port region is released.The Linux kernel CVE team has assigned CVE-2024-38630 to this issue.
Quoted 6 lines
Affected and fixed versions
===========================Issue introduced in 3.8 with commit
e09d9c3e9f85and fixed in 6.6.33 with commit9b1c063ffc07Issue introduced in 3.8 with commite09d9c3e9f85and fixed in 6.9.4 with commitf19686d61650Issue introduced in 3.8 with commite09d9c3e9f85and fixed in 6.10-rc1 with commit 573601521277For the record, this is incorrect. The Fixes tag is misleading. The commit being "fixed" was adding a missing
del_timer()call, so the situation was even worst before that, as the race window on module removal was even larger.
Quoted 5 lines
Quoted 2 lines
The bug is present since kernel v2.5.61 when the cpu5wdt driver was added to the kernel tree.
So should I change the "vulnerable" commit to be the root of git, commit
1da177e4c3f4("Linux-2.6.12-rc2"), instead?
Yes.
Signature · 2 lines
Jean Delvare SUSE L3 Support
Quoted 37 lines · Jean Delvare
Hi Greg,
Quoted 34 lines · Greg Kroah-Hartman
Quoted 33 lines · Jean Delvare
Quoted 20 lines · Greg Kroah-Hartman
Description
===========In the Linux kernel, the following vulnerability has been resolved:
watchdog:
cpu5wdt.c: Fix use-after-free bug caused bycpu5wdt_triggerWhen 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 byrelease_region()and then the timer handlercpu5wdt_trigger()callsoutb()to write into the region that is released, the use-after-free bug will happen.Change
del_timer()totimer_shutdown_sync()in order that the timer handler could be finished before the port region is released.The Linux kernel CVE team has assigned CVE-2024-38630 to this issue.
Quoted 6 lines
Affected and fixed versions
===========================Issue introduced in 3.8 with commit
e09d9c3e9f85and fixed in 6.6.33 with commit9b1c063ffc07Issue introduced in 3.8 with commite09d9c3e9f85and fixed in 6.9.4 with commitf19686d61650Issue introduced in 3.8 with commite09d9c3e9f85and fixed in 6.10-rc1 with commit 573601521277For the record, this is incorrect. The Fixes tag is misleading. The commit being "fixed" was adding a missing
del_timer()call, so the situation was even worst before that, as the race window on module removal was even larger.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
The bug is present since kernel v2.5.61 when the cpu5wdt driver was added to the kernel tree.
So should I change the "vulnerable" commit to be the root of git, commit
1da177e4c3f4("Linux-2.6.12-rc2"), instead?Yes.
Great, now done, and the json entry on cve.org is updated.
thanks for the review.
greg k-h