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().
Metrics
Affected Vendors & Products
| Source | ID | Title | 
|---|---|---|
  Debian DLA | 
                DLA-4075-1 | linux security update | 
  Debian DLA | 
                DLA-4076-1 | linux-6.1 security update | 
  EUVD | 
                EUVD-2024-53279 | 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(). | 
  Ubuntu USN | 
                USN-7379-1 | Linux kernel vulnerabilities | 
  Ubuntu USN | 
                USN-7379-2 | Linux kernel (Raspberry Pi) vulnerabilities | 
  Ubuntu USN | 
                USN-7380-1 | Linux kernel (Low Latency) vulnerabilities | 
  Ubuntu USN | 
                USN-7381-1 | Linux kernel (Low Latency) vulnerabilities | 
  Ubuntu USN | 
                USN-7382-1 | Linux kernel (OEM) vulnerabilities | 
  Ubuntu USN | 
                USN-7387-1 | Linux kernel vulnerabilities | 
  Ubuntu USN | 
                USN-7387-2 | Linux kernel (FIPS) vulnerabilities | 
  Ubuntu USN | 
                USN-7387-3 | Linux kernel (Real-time) vulnerabilities | 
  Ubuntu USN | 
                USN-7388-1 | Linux kernel vulnerabilities | 
  Ubuntu USN | 
                USN-7389-1 | Linux kernel (NVIDIA Tegra) vulnerabilities | 
  Ubuntu USN | 
                USN-7390-1 | Linux kernel (Xilinx ZynqMP) vulnerabilities | 
  Ubuntu USN | 
                USN-7391-1 | Linux kernel vulnerabilities | 
  Ubuntu USN | 
                USN-7392-1 | Linux kernel vulnerabilities | 
  Ubuntu USN | 
                USN-7392-2 | Linux kernel vulnerabilities | 
  Ubuntu USN | 
                USN-7392-3 | Linux kernel (AWS) vulnerabilities | 
  Ubuntu USN | 
                USN-7392-4 | Linux kernel (AWS FIPS) vulnerabilities | 
  Ubuntu USN | 
                USN-7393-1 | Linux kernel (FIPS) vulnerabilities | 
  Ubuntu USN | 
                USN-7401-1 | Linux kernel (AWS) vulnerabilities | 
  Ubuntu USN | 
                USN-7407-1 | Linux kernel (HWE) vulnerabilities | 
  Ubuntu USN | 
                USN-7413-1 | Linux kernel (IoT) vulnerabilities | 
  Ubuntu USN | 
                USN-7421-1 | Linux kernel (Azure) vulnerabilities | 
  Ubuntu USN | 
                USN-7449-1 | Linux kernel vulnerabilities | 
  Ubuntu USN | 
                USN-7449-2 | Linux kernel (HWE) vulnerabilities | 
  Ubuntu USN | 
                USN-7450-1 | Linux kernel vulnerabilities | 
  Ubuntu USN | 
                USN-7451-1 | Linux kernel vulnerabilities | 
  Ubuntu USN | 
                USN-7452-1 | Linux kernel vulnerabilities | 
  Ubuntu USN | 
                USN-7453-1 | Linux kernel (Real-time) vulnerabilities | 
  Ubuntu USN | 
                USN-7458-1 | Linux kernel (IBM) vulnerabilities | 
  Ubuntu USN | 
                USN-7459-1 | Linux kernel (Intel IoTG) vulnerabilities | 
  Ubuntu USN | 
                USN-7459-2 | Linux kernel (GCP) vulnerabilities | 
  Ubuntu USN | 
                USN-7463-1 | Linux kernel (IBM) vulnerabilities | 
  Ubuntu USN | 
                USN-7468-1 | Linux kernel (Azure, N-Series) vulnerabilities | 
  Ubuntu USN | 
                USN-7496-1 | Linux kernel vulnerabilities | 
  Ubuntu USN | 
                USN-7496-2 | Linux kernel (FIPS) vulnerabilities | 
  Ubuntu USN | 
                USN-7496-3 | Linux kernel (Azure) vulnerabilities | 
  Ubuntu USN | 
                USN-7496-4 | Linux kernel (Azure) vulnerabilities | 
  Ubuntu USN | 
                USN-7496-5 | Linux kernel (Azure FIPS) vulnerabilities | 
  Ubuntu USN | 
                USN-7506-1 | Linux kernel vulnerabilities | 
  Ubuntu USN | 
                USN-7506-2 | Linux kernel (AWS) vulnerabilities | 
  Ubuntu USN | 
                USN-7506-3 | Linux kernel (FIPS) vulnerabilities | 
  Ubuntu USN | 
                USN-7506-4 | Linux kernel (Xenial HWE) vulnerabilities | 
  Ubuntu USN | 
                USN-7523-1 | Linux kernel (Raspberry Pi Real-time) vulnerabilities | 
  Ubuntu USN | 
                USN-7524-1 | Linux kernel (Raspberry Pi) vulnerabilities | 
  Ubuntu USN | 
                USN-7539-1 | Linux kernel (Raspberry Pi) vulnerabilities | 
  Ubuntu USN | 
                USN-7540-1 | Linux kernel (Raspberry Pi) vulnerabilities | 
Solution
No solution given by the vendor.
Workaround
No workaround given by the vendor.
Mon, 03 Nov 2025 21:30:00 +0000
| Type | Values Removed | Values Added | 
|---|---|---|
| References | 
         | 
Wed, 14 May 2025 02:30:00 +0000
| Type | Values Removed | Values Added | 
|---|---|---|
| First Time appeared | 
        
        Redhat
         Redhat enterprise Linux  | 
|
| CPEs | cpe:/a:redhat:enterprise_linux:9 cpe:/o:redhat:enterprise_linux:9  | 
|
| Vendors & Products | 
        
        Redhat
         Redhat enterprise Linux  | 
Thu, 13 Feb 2025 00:30:00 +0000
| Type | Values Removed | Values Added | 
|---|---|---|
| Metrics | 
        
        
        threat_severity
         
  | 
    
        
        
        threat_severity
         
  | 
Tue, 11 Feb 2025 16:15:00 +0000
| Type | Values Removed | Values Added | 
|---|---|---|
| Metrics | 
        
        ssvc
         
  | 
Sun, 02 Feb 2025 10:30:00 +0000
| Type | Values Removed | Values Added | 
|---|---|---|
| References | 
         | 
Thu, 23 Jan 2025 17:15:00 +0000
| Type | Values Removed | Values Added | 
|---|---|---|
| References | 
         | 
Wed, 08 Jan 2025 22:00:00 +0000
| Type | Values Removed | Values Added | 
|---|---|---|
| First Time appeared | 
        
        Linux
         Linux linux Kernel  | 
|
| Weaknesses | CWE-416 | |
| CPEs | cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* cpe:2.3:o:linux:linux_kernel:6.13:rc1:*:*:*:*:*:*  | 
|
| Vendors & Products | 
        
        Linux
         Linux linux Kernel  | 
|
| Metrics | 
        
        
        cvssV3_1
         
  | 
    
        
        
        cvssV3_1
         
  | 
Mon, 30 Dec 2024 01:30:00 +0000
| Type | Values Removed | Values Added | 
|---|---|---|
| References | 
         | |
| Metrics | 
        
        
        threat_severity
         
  | 
    
        
        cvssV3_1
         
 
  | 
Fri, 27 Dec 2024 15:15:00 +0000
| Type | Values Removed | Values 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(). | |
| Title | scsi: sg: Fix slab-use-after-free read in sg_release() | |
| References | 
         | 
Status: PUBLISHED
Assigner: Linux
Published:
Updated: 2025-11-03T20:51:27.036Z
Reserved: 2024-12-27T15:00:39.838Z
Link: CVE-2024-56631
Updated: 2025-02-11T15:41:56.814Z
Status : Modified
Published: 2024-12-27T15:15:22.690
Modified: 2025-11-03T21:18:11.230
Link: CVE-2024-56631
                        OpenCVE Enrichment
                    No data.
 Debian DLA
 EUVD
 Ubuntu USN