Lucene search

K
cveLinuxCVE-2022-48853
HistoryJul 16, 2024 - 1:15 p.m.

CVE-2022-48853

2024-07-1613:15:12
Linux
web.nvd.nist.gov
34
linux kernel
vulnerability
fix
dma_from_device
info leak
swiotlb
sg_io
scsi
virtio-scsi
buffer
test case
tur
ltp test

CVSS3

5.5

Attack Vector

LOCAL

Attack Complexity

LOW

Privileges Required

LOW

User Interaction

NONE

Scope

UNCHANGED

Confidentiality Impact

HIGH

Integrity Impact

NONE

Availability Impact

NONE

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

AI Score

6.7

Confidence

High

EPSS

0.001

Percentile

50.6%

In the Linux kernel, the following vulnerability has been resolved:

swiotlb: fix info leak with DMA_FROM_DEVICE

The problem I’m addressing was discovered by the LTP test covering
cve-2018-1000204.

A short description of what happens follows:

  1. The test case issues a command code 00 (TEST UNIT READY) via the SG_IO
    interface with: dxfer_len == 524288, dxdfer_dir == SG_DXFER_FROM_DEV
    and a corresponding dxferp. The peculiar thing about this is that TUR
    is not reading from the device.
  2. In sg_start_req() the invocation of blk_rq_map_user() effectively
    bounces the user-space buffer. As if the device was to transfer into
    it. Since commit a45b599ad808 (β€œscsi: sg: allocate with __GFP_ZERO in
    sg_build_indirect()”) we make sure this first bounce buffer is
    allocated with GFP_ZERO.
  3. For the rest of the story we keep ignoring that we have a TUR, so the
    device won’t touch the buffer we prepare as if the we had a
    DMA_FROM_DEVICE type of situation. My setup uses a virtio-scsi device
    and the buffer allocated by SG is mapped by the function
    virtqueue_add_split() which uses DMA_FROM_DEVICE for the β€œin” sgs (here
    scatter-gather and not scsi generics). This mapping involves bouncing
    via the swiotlb (we need swiotlb to do virtio in protected guest like
    s390 Secure Execution, or AMD SEV).
  4. When the SCSI TUR is done, we first copy back the content of the second
    (that is swiotlb) bounce buffer (which most likely contains some
    previous IO data), to the first bounce buffer, which contains all
    zeros. Then we copy back the content of the first bounce buffer to
    the user-space buffer.
  5. The test case detects that the buffer, which it zero-initialized,
    ain’t all zeros and fails.

One can argue that this is an swiotlb problem, because without swiotlb
we leak all zeros, and the swiotlb should be transparent in a sense that
it does not affect the outcome (if all other participants are well
behaved).

Copying the content of the original buffer into the swiotlb buffer is
the only way I can think of to make swiotlb transparent in such
scenarios. So let’s do just that if in doubt, but allow the driver
to tell us that the whole mapped buffer is going to be overwritten,
in which case we can preserve the old behavior and avoid the performance
impact of the extra bounce.

Affected configurations

Nvd
Vulners
Node
linuxlinux_kernelRange<4.9.320
OR
linuxlinux_kernelRange4.10–4.14.281
OR
linuxlinux_kernelRange4.15–4.19.245
OR
linuxlinux_kernelRange4.20–5.4.189
OR
linuxlinux_kernelRange5.5–5.10.110
OR
linuxlinux_kernelRange5.11–5.15.29
OR
linuxlinux_kernelRange5.16–5.16.15

CNA Affected

[
  {
    "product": "Linux",
    "vendor": "Linux",
    "defaultStatus": "unaffected",
    "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
    "programFiles": [
      "Documentation/core-api/dma-attributes.rst",
      "include/linux/dma-mapping.h",
      "kernel/dma/swiotlb.c"
    ],
    "versions": [
      {
        "version": "1da177e4c3f4",
        "lessThan": "c132f2ba716b",
        "status": "affected",
        "versionType": "git"
      },
      {
        "version": "1da177e4c3f4",
        "lessThan": "971e5dadffd0",
        "status": "affected",
        "versionType": "git"
      },
      {
        "version": "1da177e4c3f4",
        "lessThan": "8d9ac1b6665c",
        "status": "affected",
        "versionType": "git"
      },
      {
        "version": "1da177e4c3f4",
        "lessThan": "6bfc5377a210",
        "status": "affected",
        "versionType": "git"
      },
      {
        "version": "1da177e4c3f4",
        "lessThan": "d4d975e79210",
        "status": "affected",
        "versionType": "git"
      },
      {
        "version": "1da177e4c3f4",
        "lessThan": "7403f4118ab9",
        "status": "affected",
        "versionType": "git"
      },
      {
        "version": "1da177e4c3f4",
        "lessThan": "270475d6d241",
        "status": "affected",
        "versionType": "git"
      },
      {
        "version": "1da177e4c3f4",
        "lessThan": "ddbd89deb7d3",
        "status": "affected",
        "versionType": "git"
      }
    ]
  },
  {
    "product": "Linux",
    "vendor": "Linux",
    "defaultStatus": "affected",
    "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
    "programFiles": [
      "Documentation/core-api/dma-attributes.rst",
      "include/linux/dma-mapping.h",
      "kernel/dma/swiotlb.c"
    ],
    "versions": [
      {
        "version": "4.9.320",
        "lessThanOrEqual": "4.9.*",
        "status": "unaffected",
        "versionType": "custom"
      },
      {
        "version": "4.14.281",
        "lessThanOrEqual": "4.14.*",
        "status": "unaffected",
        "versionType": "custom"
      },
      {
        "version": "4.19.245",
        "lessThanOrEqual": "4.19.*",
        "status": "unaffected",
        "versionType": "custom"
      },
      {
        "version": "5.4.189",
        "lessThanOrEqual": "5.4.*",
        "status": "unaffected",
        "versionType": "custom"
      },
      {
        "version": "5.10.110",
        "lessThanOrEqual": "5.10.*",
        "status": "unaffected",
        "versionType": "custom"
      },
      {
        "version": "5.15.29",
        "lessThanOrEqual": "5.15.*",
        "status": "unaffected",
        "versionType": "custom"
      },
      {
        "version": "5.16.15",
        "lessThanOrEqual": "5.16.*",
        "status": "unaffected",
        "versionType": "custom"
      },
      {
        "version": "5.17",
        "lessThanOrEqual": "*",
        "status": "unaffected",
        "versionType": "original_commit_for_fix"
      }
    ]
  }
]

CVSS3

5.5

Attack Vector

LOCAL

Attack Complexity

LOW

Privileges Required

LOW

User Interaction

NONE

Scope

UNCHANGED

Confidentiality Impact

HIGH

Integrity Impact

NONE

Availability Impact

NONE

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

AI Score

6.7

Confidence

High

EPSS

0.001

Percentile

50.6%