# CVE-2026-31412: usb: gadget: f\_mass\_storage: Fix potential integer overflow in check\_command\_size\_in\_blocks()

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** MEDIUM 5.5
- **CVSS:** 5.5 (v3.1, NVD) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: Low; Privileges required: Low; User interaction: None; Scope: Unchanged; Confidentiality impact: None; Integrity impact: None; Availability impact: High
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Not remotely exploitable (local or adjacent access needed)
- **EPSS:** 0.18% (percentile 4, 2026-11-26)
- **CWE:** CWE-190
- **Published:** 2026-04-10T10:35:05.796Z
- **Modified:** 2026-06-17T10:33:39.937Z

## Who should check

- Anyone running Linux \>= 144974e7f9e32b53b02f6c8632be45d8f43d6ab5, \< 91817ad5452defe69bc7bc0e355f0ed5d01125cc; \>= 144974e7f9e32b53b02f6c8632be45d8f43d6ab5, \< ce0caaed5940162780c5c223b8ae54968a5f059b; \>= 144974e7f9e32b53b02f6c8632be45d8f43d6ab5, \< 228b37936376143f4b60cc6828663f6eaceb81b5; \>= 144974e7f9e32b53b02f6c8632be45d8f43d6ab5, \< 3428dc5520c811e66622b2f5fa43341bf9a1f8b3; \>= 144974e7f9e32b53b02f6c8632be45d8f43d6ab5, \< 387ebb0453b99d71491419a5dc4ab4bee0cacbac; \>= 144974e7f9e32b53b02f6c8632be45d8f43d6ab5, \< 8479891d1f04a8ce55366fe4ca361ccdb96f02e1
- Anyone running Linux 3.3

## 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.

## Affected and fixed versions

- Linux: \>= 144974e7f9e32b53b02f6c8632be45d8f43d6ab5, \< 91817ad5452defe69bc7bc0e355f0ed5d01125cc; \>= 144974e7f9e32b53b02f6c8632be45d8f43d6ab5, \< ce0caaed5940162780c5c223b8ae54968a5f059b; \>= 144974e7f9e32b53b02f6c8632be45d8f43d6ab5, \< 228b37936376143f4b60cc6828663f6eaceb81b5; \>= 144974e7f9e32b53b02f6c8632be45d8f43d6ab5, \< 3428dc5520c811e66622b2f5fa43341bf9a1f8b3; \>= 144974e7f9e32b53b02f6c8632be45d8f43d6ab5, \< 387ebb0453b99d71491419a5dc4ab4bee0cacbac; \>= 144974e7f9e32b53b02f6c8632be45d8f43d6ab5, \< 8479891d1f04a8ce55366fe4ca361ccdb96f02e1 (cvelist)
- Linux: 3.3 (cvelist)

## Mitigation

- Upgrade Linux to 8479891d1f04a8ce55366fe4ca361ccdb96f02e1 or later.

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2026-31412. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2026-31412.md
Affected: Linux >= 144974e7f9e32b53b02f6c8632be45d8f43d6ab5, < 91817ad5452defe69bc7bc0e355f0ed5d01125cc; >= 144974e7f9e32b53b02f6c8632be45d8f43d6ab5, < ce0caaed5940162780c5c223b8ae54968a5f059b; >= 144974e7f9e32b53b02f6c8632be45d8f43d6ab5, < 228b37936376143f4b60cc6828663f6eaceb81b5; >= 144974e7f9e32b53b02f6c8…
Fixed in: Linux 91817ad5452defe69bc7bc0e355f0ed5d01125cc, Linux 228b37936376143f4b60cc6828663f6eaceb81b5, Linux 3428dc5520c811e66622b2f5fa43341bf9a1f8b3, Linux 387ebb0453b99d71491419a5dc4ab4bee0cacbac, Linux 8479891d1f04a8ce55366fe4ca361ccdb96f02e1

Steps:
1. Search this machine and project for Linux: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2026-31412 being exploited?

There is no confirmed exploitation: CVE-2026-31412 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.18% chance of exploitation in the next 30 days (as of 2026-11-26).

### How serious is CVE-2026-31412?

Medium: CVSS 5.5 (v3.1, scored by NVD). Not remotely exploitable (local or adjacent access needed).

### Which versions are affected by CVE-2026-31412?

Linux \>= 144974e7f9e32b53b02f6c8632be45d8f43d6ab5, \< 91817ad5452defe69bc7bc0e355f0ed5d01125cc; \>= 144974e7f9e32b53b02f6c8632be45d8f43d6ab5, \< ce0caaed5940162780c5c223b8ae54968a5f059b; \>= 144974e7f9e32b53b02f6c8632be45d8f43d6ab5, \< 228b37936376143f4b60cc6828663f6eaceb81b5; \>= 144974e7f9e32b53b02f6c8632be45d8f43d6ab5, \< 3428dc5520c811e66622b2f5fa43341bf9a1f8b3; \>= 144974e7f9e32b53b02f6c8632be45d8f43d6ab5, \< 387ebb0453b99d71491419a5dc4ab4bee0cacbac; \>= 144974e7f9e32b53b02f6c8632be45d8f43d6ab5, \< 8479891d1f04a8ce55366fe4ca361ccdb96f02e1; Linux 3.3.

### Is there a fix for CVE-2026-31412?

Yes. Fixed in Linux 91817ad5452defe69bc7bc0e355f0ed5d01125cc, Linux 228b37936376143f4b60cc6828663f6eaceb81b5, Linux 3428dc5520c811e66622b2f5fa43341bf9a1f8b3, Linux 387ebb0453b99d71491419a5dc4ab4bee0cacbac, Linux 8479891d1f04a8ce55366fe4ca361ccdb96f02e1. Upgrade Linux to 8479891d1f04a8ce55366fe4ca361ccdb96f02e1 or later.

### How do I check if I'm affected by CVE-2026-31412?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

- patch: <https://git.kernel.org/stable/c/91817ad5452defe69bc7bc0e355f0ed5d01125cc>
- patch: <https://git.kernel.org/stable/c/ce0caaed5940162780c5c223b8ae54968a5f059b>
- patch: <https://git.kernel.org/stable/c/228b37936376143f4b60cc6828663f6eaceb81b5>
- patch: <https://git.kernel.org/stable/c/3428dc5520c811e66622b2f5fa43341bf9a1f8b3>
- patch: <https://git.kernel.org/stable/c/387ebb0453b99d71491419a5dc4ab4bee0cacbac>
- patch: <https://git.kernel.org/stable/c/8479891d1f04a8ce55366fe4ca361ccdb96f02e1>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2026-31412>

HTML: <https://flawdb.com/CVE-2026-31412> · JSON: <https://flawdb.com/api/v1/entries/CVE-2026-31412>
