CVE-2022-50215 (GCVE-0-2022-50215)
Vulnerability from cvelistv5
Published
2025-06-18 11:03
Modified
2026-08-05 08:57
Summary
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.
Impacted products
Vendor Product Version
Linux Linux Version: c6517b7942fad663cc1cf3235cbe4207cf769332
Version: c6517b7942fad663cc1cf3235cbe4207cf769332
Version: c6517b7942fad663cc1cf3235cbe4207cf769332
Version: c6517b7942fad663cc1cf3235cbe4207cf769332
Version: c6517b7942fad663cc1cf3235cbe4207cf769332
Version: c6517b7942fad663cc1cf3235cbe4207cf769332
Version: c6517b7942fad663cc1cf3235cbe4207cf769332
Version: c6517b7942fad663cc1cf3235cbe4207cf769332
Version: c6517b7942fad663cc1cf3235cbe4207cf769332
Version: a0fe972f78eaaf352d593f9ed9079de590ceb286
Version: b21c6d2897cd455fa396f4041a0c8165784e949f
Version: 2.6.28.10   
Version: 2.6.29.2   
Create a notification for this product.
Show details on NVD website


{
  "containers": {
    "cna": {
      "affected": [
        {
          "defaultStatus": "unaffected",
          "product": "Linux",
          "programFiles": [
            "drivers/scsi/sg.c"
          ],
          "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
          "vendor": "Linux",
          "versions": [
            {
              "lessThan": "bbc118acf7baf9e93c5e1314d14f481301af4d0f",
              "status": "affected",
              "version": "c6517b7942fad663cc1cf3235cbe4207cf769332",
              "versionType": "git"
            },
            {
              "lessThan": "f5e61d9b4a699dd16f32d5f39eb1cf98d84c92ed",
              "status": "affected",
              "version": "c6517b7942fad663cc1cf3235cbe4207cf769332",
              "versionType": "git"
            },
            {
              "lessThan": "ed9afd967cbfe7da2dc0d5e52c62a778dfe9f16b",
              "status": "affected",
              "version": "c6517b7942fad663cc1cf3235cbe4207cf769332",
              "versionType": "git"
            },
            {
              "lessThan": "f135c65085eed869d10e4e7923ce1015288618da",
              "status": "affected",
              "version": "c6517b7942fad663cc1cf3235cbe4207cf769332",
              "versionType": "git"
            },
            {
              "lessThan": "408bfa1489a3cfe7150b81ab0b0df99b23dd5411",
              "status": "affected",
              "version": "c6517b7942fad663cc1cf3235cbe4207cf769332",
              "versionType": "git"
            },
            {
              "lessThan": "8c004b7dbb340c1e5889f5fb9e5baa6f6e5303e8",
              "status": "affected",
              "version": "c6517b7942fad663cc1cf3235cbe4207cf769332",
              "versionType": "git"
            },
            {
              "lessThan": "35e60ec39e862159cb92923eefd5230d4a873cb9",
              "status": "affected",
              "version": "c6517b7942fad663cc1cf3235cbe4207cf769332",
              "versionType": "git"
            },
            {
              "lessThan": "03d8241112d5e3cccce1a01274a221099f07d2e1",
              "status": "affected",
              "version": "c6517b7942fad663cc1cf3235cbe4207cf769332",
              "versionType": "git"
            },
            {
              "lessThan": "3455607fd7be10b449f5135c00dc306b85dc0d21",
              "status": "affected",
              "version": "c6517b7942fad663cc1cf3235cbe4207cf769332",
              "versionType": "git"
            },
            {
              "status": "affected",
              "version": "a0fe972f78eaaf352d593f9ed9079de590ceb286",
              "versionType": "git"
            },
            {
              "status": "affected",
              "version": "b21c6d2897cd455fa396f4041a0c8165784e949f",
              "versionType": "git"
            },
            {
              "lessThan": "2.6.29",
              "status": "affected",
              "version": "2.6.28.10",
              "versionType": "semver"
            },
            {
              "lessThan": "2.6.30",
              "status": "affected",
              "version": "2.6.29.2",
              "versionType": "semver"
            }
          ]
        },
        {
          "defaultStatus": "affected",
          "product": "Linux",
          "programFiles": [
            "drivers/scsi/sg.c"
          ],
          "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
          "vendor": "Linux",
          "versions": [
            {
              "status": "affected",
              "version": "2.6.30"
            },
            {
              "lessThan": "2.6.30",
              "status": "unaffected",
              "version": "0",
              "versionType": "semver"
            },
            {
              "lessThanOrEqual": "4.9.*",
              "status": "unaffected",
              "version": "4.9.326",
              "versionType": "semver"
            },
            {
              "lessThanOrEqual": "4.14.*",
              "status": "unaffected",
              "version": "4.14.291",
              "versionType": "semver"
            },
            {
              "lessThanOrEqual": "4.19.*",
              "status": "unaffected",
              "version": "4.19.256",
              "versionType": "semver"
            },
            {
              "lessThanOrEqual": "5.4.*",
              "status": "unaffected",
              "version": "5.4.211",
              "versionType": "semver"
            },
            {
              "lessThanOrEqual": "5.10.*",
              "status": "unaffected",
              "version": "5.10.137",
              "versionType": "semver"
            },
            {
              "lessThanOrEqual": "5.15.*",
              "status": "unaffected",
              "version": "5.15.61",
              "versionType": "semver"
            },
            {
              "lessThanOrEqual": "5.18.*",
              "status": "unaffected",
              "version": "5.18.18",
              "versionType": "semver"
            },
            {
              "lessThanOrEqual": "5.19.*",
              "status": "unaffected",
              "version": "5.19.2",
              "versionType": "semver"
            },
            {
              "lessThanOrEqual": "*",
              "status": "unaffected",
              "version": "6.0",
              "versionType": "original_commit_for_fix"
            }
          ]
        }
      ],
      "cpeApplicability": [
        {
          "nodes": [
            {
              "cpeMatch": [
                {
                  "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*",
                  "versionEndExcluding": "4.9.326",
                  "versionStartIncluding": "2.6.30",
                  "vulnerable": true
                },
                {
                  "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*",
                  "versionEndExcluding": "4.14.291",
                  "versionStartIncluding": "2.6.30",
                  "vulnerable": true
                },
                {
                  "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*",
                  "versionEndExcluding": "4.19.256",
                  "versionStartIncluding": "2.6.30",
                  "vulnerable": true
                },
                {
                  "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*",
                  "versionEndExcluding": "5.4.211",
                  "versionStartIncluding": "2.6.30",
                  "vulnerable": true
                },
                {
                  "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*",
                  "versionEndExcluding": "5.10.137",
                  "versionStartIncluding": "2.6.30",
                  "vulnerable": true
                },
                {
                  "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*",
                  "versionEndExcluding": "5.15.61",
                  "versionStartIncluding": "2.6.30",
                  "vulnerable": true
                },
                {
                  "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*",
                  "versionEndExcluding": "5.18.18",
                  "versionStartIncluding": "2.6.30",
                  "vulnerable": true
                },
                {
                  "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*",
                  "versionEndExcluding": "5.19.2",
                  "versionStartIncluding": "2.6.30",
                  "vulnerable": true
                },
                {
                  "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*",
                  "versionEndExcluding": "6.0",
                  "versionStartIncluding": "2.6.30",
                  "vulnerable": true
                },
                {
                  "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*",
                  "versionStartIncluding": "2.6.28.10",
                  "vulnerable": true
                },
                {
                  "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*",
                  "versionStartIncluding": "2.6.29.2",
                  "vulnerable": true
                }
              ],
              "negate": false,
              "operator": "OR"
            }
          ]
        }
      ],
      "descriptions": [
        {
          "lang": "en",
          "value": "In the Linux kernel, the following vulnerability has been resolved:\n\nscsi: sg: Allow waiting for commands to complete on removed device\n\nWhen a SCSI device is removed while in active use, currently sg will\nimmediately return -ENODEV on any attempt to wait for active commands that\nwere sent before the removal.  This is problematic for commands that use\nSG_FLAG_DIRECT_IO since the data buffer may still be in use by the kernel\nwhen userspace frees or reuses it after getting ENODEV, leading to\ncorrupted userspace memory (in the case of READ-type commands) or corrupted\ndata being sent to the device (in the case of WRITE-type commands).  This\nhas been seen in practice when logging out of a iscsi_tcp session, where\nthe iSCSI driver may still be processing commands after the device has been\nmarked for removal.\n\nChange the policy to allow userspace to wait for active sg commands even\nwhen the device is being removed.  Return -ENODEV only when there are no\nmore responses to read."
        }
      ],
      "metrics": [
        {
          "cvssV3_1": {
            "baseScore": 7.8,
            "baseSeverity": "HIGH",
            "vectorString": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H",
            "version": "3.1"
          },
          "scenarios": [
            {
              "lang": "en",
              "value": "AV:L - The bug is reached only through the local SCSI generic character device (/dev/sg*) via open/read/write/ioctl(SG_IO); it is not reachable from network packet processing or adjacent-link protocols.\nAC:L - An attacker who can open the sg device fully controls in-flight commands and, on hot-pluggable deployments (USB/optical with uaccess, iSCSI session drop), can also drive or coincide with device detachment so the ENODEV-vs-completion race does not depend on conditions outside their influence.\nPR:L - /dev/sg* for optical devices is tagged uaccess for the active seat, and disk-type sg nodes are accessible to the disk group\u2014basic local users without init-namespace root\u2014so privileges required are Low, not High.\nUI:N - The attacker can open the device, submit commands, and trigger or await removal themselves; no separate victim action such as mounting a crafted image is required.\nS:U - Impact is confined to the host kernel/sg userspace interaction under the same OS security authority; this is not a VM escape, IOMMU bypass, or other cross-boundary compromise.\nC:H - With SG_FLAG_DIRECT_IO, a WRITE after premature ENODEV can DMA reused userspace heap contents (including secrets) to the device, and the same buffer-lifetime violation is memory corruption that can be leveraged for information disclosure.\nI:H - Premature ENODEV allows DMA or bio_uncopy_user copy-back into freed/reused userspace buffers (and corrupted WRITE data to storage), which is exploitable memory corruption for integrity compromise and control-flow hijacking in the affected process.\nA:H - The resulting userspace heap corruption reliably crashes or destabilizes processes using sg on device removal, and per scoring bias for memory-corruption paths availability impact is High."
            }
          ]
        }
      ],
      "providerMetadata": {
        "dateUpdated": "2026-08-05T08:57:43.951Z",
        "orgId": "416baaa9-dc9f-4396-8d5f-8c081fb06d67",
        "shortName": "Linux"
      },
      "references": [
        {
          "url": "https://git.kernel.org/stable/c/bbc118acf7baf9e93c5e1314d14f481301af4d0f"
        },
        {
          "url": "https://git.kernel.org/stable/c/f5e61d9b4a699dd16f32d5f39eb1cf98d84c92ed"
        },
        {
          "url": "https://git.kernel.org/stable/c/ed9afd967cbfe7da2dc0d5e52c62a778dfe9f16b"
        },
        {
          "url": "https://git.kernel.org/stable/c/f135c65085eed869d10e4e7923ce1015288618da"
        },
        {
          "url": "https://git.kernel.org/stable/c/408bfa1489a3cfe7150b81ab0b0df99b23dd5411"
        },
        {
          "url": "https://git.kernel.org/stable/c/8c004b7dbb340c1e5889f5fb9e5baa6f6e5303e8"
        },
        {
          "url": "https://git.kernel.org/stable/c/35e60ec39e862159cb92923eefd5230d4a873cb9"
        },
        {
          "url": "https://git.kernel.org/stable/c/03d8241112d5e3cccce1a01274a221099f07d2e1"
        },
        {
          "url": "https://git.kernel.org/stable/c/3455607fd7be10b449f5135c00dc306b85dc0d21"
        }
      ],
      "title": "scsi: sg: Allow waiting for commands to complete on removed device",
      "x_generator": {
        "engine": "bippy-1.2.0"
      }
    }
  },
  "cveMetadata": {
    "assignerOrgId": "416baaa9-dc9f-4396-8d5f-8c081fb06d67",
    "assignerShortName": "Linux",
    "cveId": "CVE-2022-50215",
    "datePublished": "2025-06-18T11:03:52.197Z",
    "dateReserved": "2025-06-18T10:57:27.429Z",
    "dateUpdated": "2026-08-05T08:57:43.951Z",
    "state": "PUBLISHED"
  },
  "dataType": "CVE_RECORD",
  "dataVersion": "5.2"
}


Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Sightings

Author Source Type Date

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or seen somewhere by the user.
  • Confirmed: The vulnerability is confirmed from an analyst perspective.
  • Published Proof of Concept: A public proof of concept is available for this vulnerability.
  • Exploited: This vulnerability was exploited and seen by the user reporting the sighting.
  • Patched: This vulnerability was successfully patched by the user reporting the sighting.
  • Not exploited: This vulnerability was not exploited or seen by the user reporting the sighting.
  • Not confirmed: The user expresses doubt about the veracity of the vulnerability.
  • Not patched: This vulnerability was not successfully patched by the user reporting the sighting.


Loading…

Loading…