CVE-2022-50422: scsi: libsas: Fix use-after-free bug in smp_execute_task_sg()
From: Greg Kroah-Hartman <[email protected]>
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
scsi: libsas: Fix use-after-free bug in smp_execute_task_sg()
When executing SMP task failed, the smp_execute_task_sg() calls del_timer() to delete "slow_task->timer". However, if the timer handler sas_task_internal_timedout() is running, the del_timer() in smp_execute_task_sg() will not stop it and a UAF will happen. The process is shown below:
(thread 1) | (thread 2)
smp_execute_task_sg() | sas_task_internal_timedout()
... |
del_timer() |
... | ...
sas_free_task(task) |
kfree(task->slow_task) //FREE|
| task->slow_task->... //USEFix by calling del_timer_sync() in smp_execute_task_sg(), which makes sure the timer handler have finished before the "task->slow_task" is deallocated.
The Linux kernel CVE team has assigned CVE-2022-50422 to this issue.
Affected and fixed versions
===========================
Issue introduced in 2.6.19 with commit 2908d778ab3e244900c310974e1fc1c69066e450 and fixed in 5.4.220 with commit 117331a2a5227fb4369c2a1f321d3e3e2e2ef8fe Issue introduced in 2.6.19 with commit 2908d778ab3e244900c310974e1fc1c69066e450 and fixed in 5.10.150 with commit a9e5176ead6de64f572ad5c87a72825d9d3c82ae Issue introduced in 2.6.19 with commit 2908d778ab3e244900c310974e1fc1c69066e450 and fixed in 5.15.75 with commit e45a1516d2933703a4823d9db71e17c3abeba24f Issue introduced in 2.6.19 with commit 2908d778ab3e244900c310974e1fc1c69066e450 and fixed in 5.19.17 with commit f7a785177611ffc97d645fcbc196e6de6ad2421d Issue introduced in 2.6.19 with commit 2908d778ab3e244900c310974e1fc1c69066e450 and fixed in 6.0.3 with commit 2e12ce270f0d926085c1209cc90397e307deef97 Issue introduced in 2.6.19 with commit 2908d778ab3e244900c310974e1fc1c69066e450 and fixed in 6.1 with commit 46ba53c30666717cb06c2b3c5d896301cd00d0c0
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-2022-50422
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/scsi/libsas/sas_expander.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/117331a2a5227fb4369c2a1f321d3e3e2e2ef8fe https://git.kernel.org/stable/c/a9e5176ead6de64f572ad5c87a72825d9d3c82ae https://git.kernel.org/stable/c/e45a1516d2933703a4823d9db71e17c3abeba24f https://git.kernel.org/stable/c/f7a785177611ffc97d645fcbc196e6de6ad2421d https://git.kernel.org/stable/c/2e12ce270f0d926085c1209cc90397e307deef97 https://git.kernel.org/stable/c/46ba53c30666717cb06c2b3c5d896301cd00d0c0