# CVE-2021-47580: scsi: scsi\_debug: Fix type in min\_t to avoid stack OOB

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

- **Severity:** HIGH 7.1
- **CVSS:** 7.1 (v3.1, CNA) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: Low; Privileges required: Low; User interaction: None; Scope: Unchanged; Confidentiality impact: High; 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.32% (percentile 17, 2026-11-26)
- **CWE:** CWE-787
- **Published:** 2024-06-19T14:53:47.421Z
- **Modified:** 2026-08-05T08:48:28.526Z

## Who should check

- Anyone running Linux \>= 87c715dcde633f4cc4690a24a240e838181e6a9d, \< bdb854f134b964528fa543e0351022eb45bd7346; \>= 87c715dcde633f4cc4690a24a240e838181e6a9d, \< 3085147645938eb41f0bc0e25ef9791e71f5ee4b; \>= 87c715dcde633f4cc4690a24a240e838181e6a9d, \< 36e07d7ede88a1f1ef8f0f209af5b7612324ac2c
- Anyone running Linux 5.8

## Description

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

scsi: scsi\_debug: Fix type in min\_t to avoid stack OOB

Change min\_t() to use type "u32" instead of type "int" to avoid stack out
of bounds. With min\_t() type "int" the values get sign extended and the
larger value gets used causing stack out of bounds.

BUG: KASAN: stack-out-of-bounds in memcpy include/linux/fortify-string.h:191 \[inline\]
BUG: KASAN: stack-out-of-bounds in sg\_copy\_buffer+0x1de/0x240 lib/scatterlist.c:976
Read of size 127 at addr ffff888072607128 by task syz-executor.7/18707

CPU: 1 PID: 18707 Comm: syz-executor.7 Not tainted 5.15.0-syzk \#1
Hardware name: Red Hat KVM, BIOS 1.13.0-2
Call Trace:
 \_\_dump\_stack lib/dump\_stack.c:88 \[inline\]
 dump\_stack\_lvl+0x89/0xb5 lib/dump\_stack.c:106
 print\_address\_description.constprop.9+0x28/0x160 mm/kasan/report.c:256
 \_\_kasan\_report mm/kasan/report.c:442 \[inline\]
 kasan\_report.cold.14+0x7d/0x117 mm/kasan/report.c:459
 check\_region\_inline mm/kasan/generic.c:183 \[inline\]
 kasan\_check\_range+0x1a3/0x210 mm/kasan/generic.c:189
 memcpy+0x23/0x60 mm/kasan/shadow.c:65
 memcpy include/linux/fortify-string.h:191 \[inline\]
 sg\_copy\_buffer+0x1de/0x240 lib/scatterlist.c:976
 sg\_copy\_from\_buffer+0x33/0x40 lib/scatterlist.c:1000
 fill\_from\_dev\_buffer.part.34+0x82/0x130 drivers/scsi/scsi\_debug.c:1162
 fill\_from\_dev\_buffer drivers/scsi/scsi\_debug.c:1888 \[inline\]
 resp\_readcap16+0x365/0x3b0 drivers/scsi/scsi\_debug.c:1887
 schedule\_resp+0x4d8/0x1a70 drivers/scsi/scsi\_debug.c:5478
 scsi\_debug\_queuecommand+0x8c9/0x1ec0 drivers/scsi/scsi\_debug.c:7533
 scsi\_dispatch\_cmd drivers/scsi/scsi\_lib.c:1520 \[inline\]
 scsi\_queue\_rq+0x16b0/0x2d40 drivers/scsi/scsi\_lib.c:1699
 blk\_mq\_dispatch\_rq\_list+0xb9b/0x2700 block/blk-mq.c:1639
 \_\_blk\_mq\_sched\_dispatch\_requests+0x28f/0x590 block/blk-mq-sched.c:325
 blk\_mq\_sched\_dispatch\_requests+0x105/0x190 block/blk-mq-sched.c:358
 \_\_blk\_mq\_run\_hw\_queue+0xe5/0x150 block/blk-mq.c:1761
 \_\_blk\_mq\_delay\_run\_hw\_queue+0x4f8/0x5c0 block/blk-mq.c:1838
 blk\_mq\_run\_hw\_queue+0x18d/0x350 block/blk-mq.c:1891
 blk\_mq\_sched\_insert\_request+0x3db/0x4e0 block/blk-mq-sched.c:474
 blk\_execute\_rq\_nowait+0x16b/0x1c0 block/blk-exec.c:62
 sg\_common\_write.isra.18+0xeb3/0x2000 drivers/scsi/sg.c:836
 sg\_new\_write.isra.19+0x570/0x8c0 drivers/scsi/sg.c:774
 sg\_ioctl\_common+0x14d6/0x2710 drivers/scsi/sg.c:939
 sg\_ioctl+0xa2/0x180 drivers/scsi/sg.c:1165
 vfs\_ioctl fs/ioctl.c:51 \[inline\]
 \_\_do\_sys\_ioctl fs/ioctl.c:874 \[inline\]
 \_\_se\_sys\_ioctl fs/ioctl.c:860 \[inline\]
 \_\_x64\_sys\_ioctl+0x19d/0x220 fs/ioctl.c:860
 do\_syscall\_x64 arch/x86/entry/common.c:50 \[inline\]
 do\_syscall\_64+0x3a/0x80 arch/x86/entry/common.c:80
 entry\_SYSCALL\_64\_after\_hwframe+0x44/0xae

## Affected and fixed versions

- Linux: \>= 87c715dcde633f4cc4690a24a240e838181e6a9d, \< bdb854f134b964528fa543e0351022eb45bd7346; \>= 87c715dcde633f4cc4690a24a240e838181e6a9d, \< 3085147645938eb41f0bc0e25ef9791e71f5ee4b; \>= 87c715dcde633f4cc4690a24a240e838181e6a9d, \< 36e07d7ede88a1f1ef8f0f209af5b7612324ac2c (cvelist)
- Linux: 5.8 (cvelist)

## Mitigation

- Upgrade Linux to 36e07d7ede88a1f1ef8f0f209af5b7612324ac2c or later.

## Check your systems with an agent

Paste this into a coding agent:

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

Details: https://flawdb.com/CVE-2021-47580.md
Affected: Linux >= 87c715dcde633f4cc4690a24a240e838181e6a9d, < bdb854f134b964528fa543e0351022eb45bd7346; >= 87c715dcde633f4cc4690a24a240e838181e6a9d, < 3085147645938eb41f0bc0e25ef9791e71f5ee4b; >= 87c715dcde633f4cc4690a24a240e838181e6a9d, < 36e07d7ede88a1f1ef8f0f209af5b7612324ac2c; Linux 5.8
Fixed in: Linux 3085147645938eb41f0bc0e25ef9791e71f5ee4b, Linux 36e07d7ede88a1f1ef8f0f209af5b7612324ac2c

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-2021-47580 being exploited?

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

### How serious is CVE-2021-47580?

High: CVSS 7.1 (v3.1, scored by CNA). Not remotely exploitable (local or adjacent access needed).

### Which versions are affected by CVE-2021-47580?

Linux \>= 87c715dcde633f4cc4690a24a240e838181e6a9d, \< bdb854f134b964528fa543e0351022eb45bd7346; \>= 87c715dcde633f4cc4690a24a240e838181e6a9d, \< 3085147645938eb41f0bc0e25ef9791e71f5ee4b; \>= 87c715dcde633f4cc4690a24a240e838181e6a9d, \< 36e07d7ede88a1f1ef8f0f209af5b7612324ac2c; Linux 5.8.

### Is there a fix for CVE-2021-47580?

Yes. Fixed in Linux 3085147645938eb41f0bc0e25ef9791e71f5ee4b, Linux 36e07d7ede88a1f1ef8f0f209af5b7612324ac2c. Upgrade Linux to 36e07d7ede88a1f1ef8f0f209af5b7612324ac2c or later.

### How do I check if I'm affected by CVE-2021-47580?

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/bdb854f134b964528fa543e0351022eb45bd7346>
- patch: <https://git.kernel.org/stable/c/3085147645938eb41f0bc0e25ef9791e71f5ee4b>
- patch: <https://git.kernel.org/stable/c/36e07d7ede88a1f1ef8f0f209af5b7612324ac2c>

## 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-2021-47580>

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