VDB

CVE-2024-56631

CVE-2024-56631 PUBLISHED CVSS 7.8 HIGH

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.

PackageEcosystemFixed in
kernel-tools-develAmazon Linux6.1.127-135.201.amzn2023
kernel-libbpf-staticAmazon Linux6.1.127-135.201.amzn2023
kernel-headersAmazon Linux6.1.127-135.201.amzn2023
perfAmazon Linux4.14.355-274.598.amzn2
kernel-livepatch-6.1.127-135.201Amazon Linux1.0-0.amzn2023
kernel-develAmazon Linux4.14.355-274.598.amzn2
kernel-modules-extraAmazon Linux6.1.127-135.201.amzn2023
kernel-livepatch-4.14.355-274.598Amazon Linux1.0-0.amzn2
kernel-toolsAmazon Linux4.14.355-274.598.amzn2
SIMATIC S7-1500 TM MFP - GNU/Linux subsystemSiemens1.1.1

Risk scores

CVSS 3.1
7.8
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

Affected products

VendorProductVersions
LinuxLinuxcc833acbee9db5ca8c6162b015b4c93863c6f821, cc833acbee9db5ca8c6162b015b4c93863c6f821, cc833acbee9db5ca8c6162b015b4c93863c6f821
LinuxLinux3.17, 0, 5.4.290
amazon:2023kernel-tools-devel0
amazon:2023kernel-libbpf-static0
amazon:2023kernel-headers0
amazon:2perf0
SiemensSIPLUS S7-1500 CPU 1518-4 PN/DP MFP3.1.6, 3.1.7
amazon:2023kernel-livepatch-6.1.127-135.2010
SiemensSIMATIC S7-1500 CPU 1518F-4 PN/DP MFP (6ES7518-4FX00-1AC0)3.1.6, 3.1.7
amazon:2kernel-devel0
amazon:2023kernel-modules-extra0
amazon:2kernel-livepatch-4.14.355-274.5980
amazon:2kernel-tools0
SiemensSIMATIC S7-1500 TM MFP - GNU/Linux subsystem0
linuxlinux_kernel3.17, 3.17, 3.17
amazon:2023perf0
SiemensSIMATIC S7-1500 CPU 1518-4 PN/DP MFP (6ES7518-4AX00-1AC0)3.1.7, 3.1.6
amazon:2023kernel-libbpf-devel0
SiemensSIMATIC S7-1500 CPU 1518F-4 PN/DP MFP3.1.7, 3.1.6
SiemensSIPLUS 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

Look up in the Resolve Platform →
$ Lookup Community · 50/day Open Lookup ›