CVE-2022-50215
kernel: scsi: sg: Allow waiting for commands to complete on removed device
Severity
ModerateRed Hat Product Security
CVSS 3.1
Review impact separately from score.
Published · June 18, 2025
Updated · October 30, 2026
Description
In the Linux kernel, the following vulnerability has been resolved:
scsi: sg: Allow waiting for commands to complete on removed device
When a SCSI device is removed while in active use, currently sg will immediately return -ENODEV on any attempt to wait for active commands that were sent before the removal. This is problematic for commands that use SG_FLAG_DIRECT_IO since the data buffer may still be in use by the kernel when userspace frees or reuses it after getting ENODEV, leading to corrupted userspace memory (in the case of READ-type commands) or corrupted data being sent to the device (in the case of WRITE-type commands). This has been seen in practice when logging out of a iscsi_tcp session, where the iSCSI driver may still be processing commands after the device has been marked for removal.
Change the policy to allow userspace to wait for active sg commands even when the device is being removed. Return -ENODEV only when there are no more responses to read.
Statement
Red Hat has rated this vulnerability as Moderate severity because exploiting this race condition requires local access with elevated privileges to interact with raw SCSI generic character interfaces or manage storage sessions, alongside precise timing during device detachment. In standard Red Hat Enterprise Linux configurations, direct I/O via generic SCSI endpoints is typically restricted to specialized storage administration tools, significantly limiting general exposure. Although an abrupt disconnection during active operations may lead to userspace memory or storage data corruption, it does not permit unauthenticated remote compromise.
CVSS score applicability
The CVSS score(s) listed for this vulnerability do not reflect the associated product's status, and are included for informational purposes to better understand the severity of this vulnerability.
Mitigation
No mitigation is specified in collected source.
CVSS / CWE
CVSS 3.1 · 6CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:U/C:H/I:H/A:L
CWE-826 · Premature Release of Resource During Expected Lifetime