CVE-2026-31412

usb: gadget: f_mass_storage: Fix potential integer overflow in check_command_size_in_blocks()

Published Apr 10, 2026 CVSS 3.1 · 5.5 Medium EPSS < 1% KEV · Not listed
Description
In the Linux kernel, the following vulnerability has been resolved:

usb: gadget: f_mass_storage: Fix potential integer overflow in check_command_size_in_blocks()

The `check_command_size_in_blocks()` function calculates the data size
in bytes by left shifting `common->data_size_from_cmnd` by the block
size (`common->curlun->blkbits`). However, it does not validate whether
this shift operation will cause an integer overflow.

Initially, the block size is set up in `fsg_lun_open()` , and the
`common->data_size_from_cmnd` is set up in `do_scsi_command()`. During
initialization, there is no integer overflow check for the interaction
between two variables.

So if a malicious USB host sends a SCSI READ or WRITE command
requesting a large amount of data (`common->data_size_from_cmnd`), the
left shift operation can wrap around. This results in a truncated data
size, which can bypass boundary checks and potentially lead to memory
corruption or out-of-bounds accesses.

Fix this by using the check_shl_overflow() macro to safely perform the
shift and catch any overflows.

Analysis

AI-generated

Technical impact

The flaw lies in the f_mass_storage driver, where the function check_command_size_in_blocks() shifts a size value by the block size without checking for overflow. If a host issues a SCSI READ or WRITE command that requests a large data size, the shift can wrap, producing a truncated value. This bypasses buffer boundary checks and can lead to memory corruption or out‑of‑bounds accesses inside the kernel. The weakness corresponds to an unchecked shift operator vulnerability. This overflow is a classic integer overflow issue (CWE-190).\n

Affected Systems

Affected are all Linux kernel builds that include the f_mass_storage gadget driver and have not applied the patch referred to in the commit logs. No specific kernel version range is listed, so any kernel with the default f_mass_storage implementation is potentially vulnerable.\n

Risk and Exploitability

According to the available metrics, the EPSS score is below 1 % and the vulnerability is not listed in the CISA KEV catalog, indicating low current exploitation probability. However, a malicious USB host controlling SCSI commands could trigger the overflow. The attack requires physical or remote access to a USB host that can exchange SCSI commands with the device, and exploitation would likely result in kernel memory corruption, potentially escalating privileges or causing a crash. The CVSS score of 5.5 indicates a moderate level of severity.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Apply a Linux kernel update that includes the patch for check_shl_overflow() in the f_mass_storage driver (see commit logs provided in the references).
  • If an immediate kernel upgrade is not feasible, disable the f_mass_storage gadget module or restrict USB access to trusted hosts to prevent malicious SCSI command injection.
  • Verify that the kernel configuration has the f_mass_storage gadget enabled only on platforms that require it, and consider enabling kernel bounds checking or address space layout randomization to reduce the impact of potential memory corruption.

Generated by OpenCVE AI on May 20, 2026 at 17:40 UTC.

Tracking

Sign in to view the affected projects.

Advisories

Source ID Title
Debian DLA Debian DLA DLA-4561-1 linux-6.1 security update
Debian DSA Debian DSA DSA-6238-1 linux security update
Debian DSA Debian DSA DSA-6243-1 linux security update
Ubuntu USN Ubuntu USN USN-8567-1 Linux kernel vulnerabilities
Ubuntu USN Ubuntu USN USN-8574-1 Linux kernel (GCP FIPS) vulnerabilities
Ubuntu USN Ubuntu USN USN-8574-2 Linux kernel vulnerabilities
Ubuntu USN Ubuntu USN USN-8595-1 Linux kernel (Oracle) vulnerabilities
Ubuntu USN Ubuntu USN USN-8596-1 Linux kernel (NVIDIA) vulnerabilities
Ubuntu USN Ubuntu USN USN-8595-2 Linux kernel (AWS) vulnerabilities
Ubuntu USN Ubuntu USN USN-8606-1 Linux kernel (Azure) vulnerabilities
Ubuntu USN Ubuntu USN USN-8607-1 Linux kernel (Azure CVM) vulnerabilities
Ubuntu USN Ubuntu USN USN-8608-1 Linux kernel (Azure FIPS) vulnerabilities
Ubuntu USN Ubuntu USN USN-8609-1 Linux kernel (Azure CVM) vulnerabilities
Ubuntu USN Ubuntu USN USN-8574-3 Linux kernel vulnerabilities
Ubuntu USN Ubuntu USN USN-8595-3 Linux kernel (AWS) vulnerabilities
Ubuntu USN Ubuntu USN USN-8619-1 Linux kernel (HWE) vulnerabilities
Ubuntu USN Ubuntu USN USN-8665-1 Linux kernel (Raspberry Pi) vulnerabilities
History
Type Values Removed Values Added
Weaknesses CWE-190
CPEs cpe:2.3:o:linux:linux_kernel:7.0:rc1:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:7.0:rc2:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:7.0:rc3:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:7.0:rc4:*:*:*:*:*:*
Metrics cvssV3_1

{'score': 5.5, 'vector': 'CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H'}

Type Values Removed Values Added
Description In the Linux kernel, the following vulnerability has been resolved: usb: gadget: f_mass_storage: Fix potential integer overflow in check_command_size_in_blocks() The `check_command_size_in_blocks()` function calculates the data size in bytes by left shifting `common->data_size_from_cmnd` by the block size (`common->curlun->blkbits`). However, it does not validate whether this shift operation will cause an integer overflow. Initially, the block size is set up in `fsg_lun_open()` , and the `common->data_size_from_cmnd` is set up in `do_scsi_command()`. During initialization, there is no integer overflow check for the interaction between two variables. So if a malicious USB host sends a SCSI READ or WRITE command requesting a large amount of data (`common->data_size_from_cmnd`), the left shift operation can wrap around. This results in a truncated data size, which can bypass boundary checks and potentially lead to memory corruption or out-of-bounds accesses. Fix this by using the check_shl_overflow() macro to safely perform the shift and catch any overflows.
Title usb: gadget: f_mass_storage: Fix potential integer overflow in check_command_size_in_blocks()
First Time appeared Linux
Linux linux Kernel
CPEs cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
Vendors & Products Linux
Linux linux Kernel
References
Weaknesses
  • CWE-1335

    Incorrect Bitwise Shift of Integer

  • CWE-190

    Integer Overflow or Wraparound

Sources

Status
PUBLISHED
Assigner
Linux
Published
Updated
May 11, 2026, 10:08 PM
Reserved
Mar 9, 2026, 3:48 PM
Status
Analyzed
Published
Apr 10, 2026, 11:16 AM
Modified
Jun 17, 2026, 10:33 AM
Severity
Public date
Apr 10, 2026, 12:00 AM