CVE-2024-56631
Linux Kernel SCSI SG Use After Free Vulnerability
Description
In the Linux kernel, the following vulnerability has been resolved: scsi: sg: Fix slab-use-after-free read in sg_release() Fix a use-after-free bug in sg_release(), detected by syzbot with KASAN: BUG: KASAN: slab-use-after-free in lock_release+0x151/0xa30 kernel/locking/lockdep.c:5838 __mutex_unlock_slowpath+0xe2/0x750 kernel/locking/mutex.c:912 sg_release+0x1f4/0x2e0 drivers/scsi/sg.c:407 In sg_release(), the function kref_put(&sfp->f_ref, sg_remove_sfp) is called before releasing the open_rel_lock mutex. The kref_put() call may decrement the reference count of sfp to zero, triggering its cleanup through sg_remove_sfp(). This cleanup includes scheduling deferred work via sg_remove_sfp_usercontext(), which ultimately frees sfp. After kref_put(), sg_release() continues to unlock open_rel_lock and may reference sfp or sdp. If sfp has already been freed, this results in a slab-use-after-free error. Move the kref_put(&sfp->f_ref, sg_remove_sfp) call after unlocking the open_rel_lock mutex. This ensures: - No references to sfp or sdp occur after the reference count is decremented. - Cleanup functions such as sg_remove_sfp() and sg_remove_sfp_usercontext() can safely execute without impacting the mutex handling in sg_release(). The fix has been tested and validated by syzbot. This patch closes the bug reported at the following syzkaller link and ensures proper sequencing of resource cleanup and mutex operations, eliminating the risk of use-after-free errors in sg_release().
INFO
Published Date :
Dec. 27, 2024, 3:15 p.m.
Last Modified :
Feb. 11, 2025, 4:15 p.m.
Source :
416baaa9-dc9f-4396-8d5f-8c081fb06d67
Remotely Exploitable :
No
Impact Score :
5.9
Exploitability Score :
1.8
Public PoC/Exploit Available at Github
CVE-2024-56631 has a 1 public PoC/Exploit
available at Github.
Go to the Public Exploits
tab to see the list.
References to Advisories, Solutions, and Tools
Here, you will find a curated list of external links that provide in-depth
information, practical solutions, and valuable tools related to
CVE-2024-56631
.
We scan GitHub repositories to detect new proof-of-concept exploits. Following list is a collection of public exploits and proof-of-concepts, which have been published on GitHub (sorted by the most recently updated).
DSA and DLA for Debian last 14 days
Python
Results are limited to the first 15 repositories due to potential performance issues.
The following list is the news that have been mention
CVE-2024-56631
vulnerability anywhere in the article.
The following table lists the changes that have been made to the
CVE-2024-56631
vulnerability over time.
Vulnerability history details can be useful for understanding the evolution of a vulnerability, and for identifying the most recent changes that may impact the vulnerability's severity, exploitability, or other characteristics.
-
CVE Modified by 134c704f-9b21-4f2e-91b3-4a467353bcc0
Feb. 11, 2025
Action Type Old Value New Value Added CVSS V3.1 AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H Added CWE CWE-416 -
CVE Modified by 416baaa9-dc9f-4396-8d5f-8c081fb06d67
Feb. 02, 2025
Action Type Old Value New Value Added Reference https://git.kernel.org/stable/c/285ce1f89f8d414e7eecab5ef5118cd512596318 Added Reference https://git.kernel.org/stable/c/e19acb1926c4a1f30ee1ec84d8afba2d975bd534 -
CVE Modified by 416baaa9-dc9f-4396-8d5f-8c081fb06d67
Jan. 23, 2025
Action Type Old Value New Value Added Reference https://git.kernel.org/stable/c/198b89dd5a595ee3f96e5ce5c448b0484cd0e53c Added Reference https://git.kernel.org/stable/c/275b8347e21ab8193e93223a8394a806e4ba8918 -
Initial Analysis by [email protected]
Jan. 08, 2025
Action Type Old Value New Value Added CVSS V3.1 NIST AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H Added CWE NIST CWE-416 Added CPE Configuration OR *cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* versions from (including) 3.16.85 up to (excluding) 6.6.66 *cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* versions from (including) 6.7 up to (excluding) 6.12.5 *cpe:2.3:o:linux:linux_kernel:6.13:rc1:*:*:*:*:*:* Changed Reference Type https://git.kernel.org/stable/c/1f5e2f1ca5875728fcf62bc1a054707444ab4960 No Types Assigned https://git.kernel.org/stable/c/1f5e2f1ca5875728fcf62bc1a054707444ab4960 Patch Changed Reference Type https://git.kernel.org/stable/c/59b30afa578637169e2819536bb66459fdddc39d No Types Assigned https://git.kernel.org/stable/c/59b30afa578637169e2819536bb66459fdddc39d Patch Changed Reference Type https://git.kernel.org/stable/c/f10593ad9bc36921f623361c9e3dd96bd52d85ee No Types Assigned https://git.kernel.org/stable/c/f10593ad9bc36921f623361c9e3dd96bd52d85ee Patch -
New CVE Received by 416baaa9-dc9f-4396-8d5f-8c081fb06d67
Dec. 27, 2024
Action Type Old Value New Value Added Description In the Linux kernel, the following vulnerability has been resolved: scsi: sg: Fix slab-use-after-free read in sg_release() Fix a use-after-free bug in sg_release(), detected by syzbot with KASAN: BUG: KASAN: slab-use-after-free in lock_release+0x151/0xa30 kernel/locking/lockdep.c:5838 __mutex_unlock_slowpath+0xe2/0x750 kernel/locking/mutex.c:912 sg_release+0x1f4/0x2e0 drivers/scsi/sg.c:407 In sg_release(), the function kref_put(&sfp->f_ref, sg_remove_sfp) is called before releasing the open_rel_lock mutex. The kref_put() call may decrement the reference count of sfp to zero, triggering its cleanup through sg_remove_sfp(). This cleanup includes scheduling deferred work via sg_remove_sfp_usercontext(), which ultimately frees sfp. After kref_put(), sg_release() continues to unlock open_rel_lock and may reference sfp or sdp. If sfp has already been freed, this results in a slab-use-after-free error. Move the kref_put(&sfp->f_ref, sg_remove_sfp) call after unlocking the open_rel_lock mutex. This ensures: - No references to sfp or sdp occur after the reference count is decremented. - Cleanup functions such as sg_remove_sfp() and sg_remove_sfp_usercontext() can safely execute without impacting the mutex handling in sg_release(). The fix has been tested and validated by syzbot. This patch closes the bug reported at the following syzkaller link and ensures proper sequencing of resource cleanup and mutex operations, eliminating the risk of use-after-free errors in sg_release(). Added Reference https://git.kernel.org/stable/c/1f5e2f1ca5875728fcf62bc1a054707444ab4960 Added Reference https://git.kernel.org/stable/c/59b30afa578637169e2819536bb66459fdddc39d Added Reference https://git.kernel.org/stable/c/f10593ad9bc36921f623361c9e3dd96bd52d85ee
CWE - Common Weakness Enumeration
While CVE identifies
specific instances of vulnerabilities, CWE categorizes the common flaws or
weaknesses that can lead to vulnerabilities. CVE-2024-56631
is
associated with the following CWEs:
Common Attack Pattern Enumeration and Classification (CAPEC)
Common Attack Pattern Enumeration and Classification
(CAPEC)
stores attack patterns, which are descriptions of the common attributes and
approaches employed by adversaries to exploit the CVE-2024-56631
weaknesses.