CVE-2024-56631
scsi: sg: Fix slab-use-after-free read in sg_release()
Reported by linux · Published December 27, 2024
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().
Fixed versions
Upgrade to a fixed version or later. Language registries are listed first, then Linux distributions, then vendor products.
| Package | Ecosystem | Fixed in |
|---|---|---|
| kernel-tools-devel | Amazon Linux | 6.1.127-135.201.amzn2023 |
| kernel-libbpf-static | Amazon Linux | 6.1.127-135.201.amzn2023 |
| kernel-headers | Amazon Linux | 6.1.127-135.201.amzn2023 |
| perf | Amazon Linux | 4.14.355-274.598.amzn2 |
| kernel-livepatch-6.1.127-135.201 | Amazon Linux | 1.0-0.amzn2023 |
| kernel-devel | Amazon Linux | 4.14.355-274.598.amzn2 |
| kernel-modules-extra | Amazon Linux | 6.1.127-135.201.amzn2023 |
| kernel-livepatch-4.14.355-274.598 | Amazon Linux | 1.0-0.amzn2 |
| kernel-tools | Amazon Linux | 4.14.355-274.598.amzn2 |
| SIMATIC S7-1500 TM MFP - GNU/Linux subsystem | Siemens | 1.1.1 |
Risk scores
Affected products
| Vendor | Product | Versions |
|---|---|---|
| Linux | Linux | cc833acbee9db5ca8c6162b015b4c93863c6f821, cc833acbee9db5ca8c6162b015b4c93863c6f821, cc833acbee9db5ca8c6162b015b4c93863c6f821 |
| Linux | Linux | 3.17, 0, 5.4.290 |
| amazon:2023 | kernel-tools-devel | 0 |
| amazon:2023 | kernel-libbpf-static | 0 |
| amazon:2023 | kernel-headers | 0 |
| amazon:2 | perf | 0 |
| Siemens | SIPLUS S7-1500 CPU 1518-4 PN/DP MFP | 3.1.6, 3.1.7 |
| amazon:2023 | kernel-livepatch-6.1.127-135.201 | 0 |
| Siemens | SIMATIC S7-1500 CPU 1518F-4 PN/DP MFP (6ES7518-4FX00-1AC0) | 3.1.6, 3.1.7 |
| amazon:2 | kernel-devel | 0 |
| amazon:2023 | kernel-modules-extra | 0 |
| amazon:2 | kernel-livepatch-4.14.355-274.598 | 0 |
| amazon:2 | kernel-tools | 0 |
| Siemens | SIMATIC S7-1500 TM MFP - GNU/Linux subsystem | 0 |
| linux | linux_kernel | 3.17, 3.17, 3.17 |
| amazon:2023 | perf | 0 |
| Siemens | SIMATIC S7-1500 CPU 1518-4 PN/DP MFP (6ES7518-4AX00-1AC0) | 3.1.7, 3.1.6 |
| amazon:2023 | kernel-libbpf-devel | 0 |
| Siemens | SIMATIC S7-1500 CPU 1518F-4 PN/DP MFP | 3.1.7, 3.1.6 |
| Siemens | SIPLUS S7-1500 CPU 1518-4 PN/DP MFP (6AG1518-4AX00-4AC0) | 3.1.7, 3.1.6 |
…and 15 more
Timeline
- Dec 27, 2024 CVE Published
- Dec 28, 2024 EPSS Score (30 in total, the first dated here)
- Feb 23, 2025 Coalition ESS Score (12 in total, the first dated here)
- Dec 16, 2025 PoC Published
- Dec 29, 2025 Security Advisory (451 in total, the first dated here)
- Apr 29, 2026 Distribution Patch (369 in total, the first dated here)
Query this with the API
The same record, from the CLI:
vulnetix vdb vuln CVE-2024-56631
vulnetix vdb fixes CVE-2024-56631
Or with curl, using the org id and key from your account page:
curl -s -H "Authorization: ApiKey ${VULNETIX_ORG_ID}:${VULNETIX_API_KEY}" \
"https://api.vdb.vulnetix.com/v2/vuln/CVE-2024-56631/fixes/registry"
The Community plan is free and allows 50 queries a day. Get a free API key · API quickstart
References
- https://lists.debian.org/debian-lts-announce/2025/03/msg00001.html url
- https://lists.debian.org/debian-lts-announce/2025/03/msg00002.html url
- https://cert-portal.siemens.com/productcert/html/ssa-265688.html url
- https://cert-portal.siemens.com/productcert/html/ssa-019113.html url
- https://cert-portal.siemens.com/productcert/html/ssa-457936.html url