{"id":"CVE-2026-31412","aliases":["CVE-2026-31412"],"related":[],"kind":"vulnerability","state":"published","title":"usb: gadget: f_mass_storage: Fix potential integer overflow in check_command_size_in_blocks()","summary":"In the Linux kernel, the following vulnerability has been resolved:\n\nusb: gadget: f_mass_storage: Fix potential integer overflow in check_command_size_in_blocks()\n\nThe `check_command_size_in_blocks()` function calculates the data size\nin bytes by left shifting `common->data_size_from_cmnd` by the block\nsize (`common->curlun->blkbits`). However, it does not validate whether\nthis shift operation will cause an integer overflow.\n\nInitially, the block size is set up in `fsg_lun_open()` , and the\n`common->data_size_from_cmnd` is set up in `do_scsi_command()`. During\ninitialization, there is no integer overflow check for the interaction\nbetween two variables.\n\nSo if a malicious USB host sends a SCSI READ or WRITE command\nrequesting a large amount of data (`common->data_size_from_cmnd`), the\nleft shift operation can wrap around. This results in a truncated data\nsize, which can bypass boundary checks and potentially lead to memory\ncorruption or out-of-bounds accesses.\n\nFix this by using the check_shl_overflow() macro to safely perform the\nshift and catch any overflows.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"In the Linux kernel, the following vulnerability has been resolved:\n\nusb: gadget: f_mass_storage: Fix potential integer overflow in check_command_size_in_blocks()\n\nThe `check_command_size_in_blocks()` function calculates the data size\nin bytes by left shifting `common->data_size_from_cmnd` by the block\nsize (`common->curlun->blkbits`). However, it does not validate whether\nthis shift operation will cause an integer overflow.\n\nInitially, the block size is set up in `fsg_lun_open()` , and the\n`common->data_size_from_cmnd` is set up in `do_scsi_command()`. During\ninitialization, there is no integer overflow check for the interaction\nbetween two variables.\n\nSo if a malicious USB host sends a SCSI READ or WRITE command\nrequesting a large amount of data (`common->data_size_from_cmnd`), the\nleft shift operation can wrap around. This results in a truncated data\nsize, which can bypass boundary checks and potentially lead to memory\ncorruption or out-of-bounds accesses.\n\nFix this by using the check_shl_overflow() macro to safely perform the\nshift and catch any overflows.","source":"cvelist"}],"published":"2026-04-10T10:35:05.796Z","modified":"2026-06-17T10:33:39.937Z","severity":{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H","score":5.5,"rating":"MEDIUM"},"severities":[{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H","score":5.5,"rating":"MEDIUM"}],"cwes":["CWE-190"],"affected":[{"ranges":[{"type":"git","introduced":"144974e7f9e32b53b02f6c8632be45d8f43d6ab5","fixed":"91817ad5452defe69bc7bc0e355f0ed5d01125cc","status":"affected"},{"type":"git","introduced":"144974e7f9e32b53b02f6c8632be45d8f43d6ab5","fixed":"ce0caaed5940162780c5c223b8ae54968a5f059b","status":"affected"},{"type":"git","introduced":"144974e7f9e32b53b02f6c8632be45d8f43d6ab5","fixed":"228b37936376143f4b60cc6828663f6eaceb81b5","status":"affected"},{"type":"git","introduced":"144974e7f9e32b53b02f6c8632be45d8f43d6ab5","fixed":"3428dc5520c811e66622b2f5fa43341bf9a1f8b3","status":"affected"},{"type":"git","introduced":"144974e7f9e32b53b02f6c8632be45d8f43d6ab5","fixed":"387ebb0453b99d71491419a5dc4ab4bee0cacbac","status":"affected"},{"type":"git","introduced":"144974e7f9e32b53b02f6c8632be45d8f43d6ab5","fixed":"8479891d1f04a8ce55366fe4ca361ccdb96f02e1","status":"affected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"version":"3.3","status":"affected"},{"type":"semver","introduced":"0","fixed":"3.3","status":"unaffected"},{"type":"semver","introduced":"6.1.167","lastAffected":"6.1.*","status":"unaffected"},{"type":"semver","introduced":"6.6.130","lastAffected":"6.6.*","status":"unaffected"},{"type":"semver","introduced":"6.12.78","lastAffected":"6.12.*","status":"unaffected"},{"type":"semver","introduced":"6.18.19","lastAffected":"6.18.*","status":"unaffected"},{"type":"semver","introduced":"6.19.9","lastAffected":"6.19.*","status":"unaffected"},{"type":"original_commit_for_fix","introduced":"7.0","lastAffected":"*","status":"unaffected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"status":"affected","introduced":"3.3","fixed":"6.1.167"},{"status":"affected","introduced":"6.2","fixed":"6.6.130"},{"status":"affected","introduced":"6.7","fixed":"6.12.78"},{"status":"affected","introduced":"6.13","fixed":"6.18.19"},{"status":"affected","introduced":"6.19","fixed":"6.19.9"},{"status":"affected","version":"7.0"},{"status":"affected","version":"7.0"},{"status":"affected","version":"7.0"},{"status":"affected","version":"7.0"}],"vendor":"linux","product":"linux_kernel","cpe":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://git.kernel.org/stable/c/91817ad5452defe69bc7bc0e355f0ed5d01125cc","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/ce0caaed5940162780c5c223b8ae54968a5f059b","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/228b37936376143f4b60cc6828663f6eaceb81b5","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/3428dc5520c811e66622b2f5fa43341bf9a1f8b3","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/387ebb0453b99d71491419a5dc4ab4bee0cacbac","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/8479891d1f04a8ce55366fe4ca361ccdb96f02e1","tags":["patch"],"sources":["cvelist","nvd"]}],"credits":[],"assigner":"Linux","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-31412","url":"https://www.cve.org/CVERecord?id=CVE-2026-31412","licence":"CVE Terms of Use","modified":"2026-05-11T22:08:12.685Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-31412","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-31412","licence":"Public domain","modified":"2026-06-17T10:33:39.937Z"}],"updatedAt":"2026-11-25T22:59:18.491Z","epss":{"score":0.00176,"percentile":0.07479,"date":"2026-12-01T12:00:22.000Z"}}