# CVE-2021-47578: scsi: scsi\_debug: Don't call kcalloc() if size arg is zero

> 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.31% (percentile 16, 2026-11-26)
- **CWE:** CWE-476
- **Published:** 2024-06-19T14:53:46.061Z
- **Modified:** 2026-06-17T04:17:48.173Z

## Who should check

- Anyone running Linux \>= c3e2fe9222d428f115baeba2f6b3637b3aa444cd, \< aa1f912712a109b6306746133de7e5343f016b26; \>= c3e2fe9222d428f115baeba2f6b3637b3aa444cd, \< 47d11d35203b0aa13533634e270fe2c3610e531b; \>= c3e2fe9222d428f115baeba2f6b3637b3aa444cd, \< 3344b58b53a76199dae48faa396e9fc37bf86992
- Anyone running Linux 5.8

## Description

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

scsi: scsi\_debug: Don't call kcalloc() if size arg is zero

If the size arg to kcalloc() is zero, it returns ZERO\_SIZE\_PTR.  Because of
that, for a following NULL pointer check to work on the returned pointer,
kcalloc() must not be called with the size arg equal to zero. Return early
without error before the kcalloc() call if size arg is zero.

BUG: KASAN: null-ptr-deref in memcpy include/linux/fortify-string.h:191 \[inline\]
BUG: KASAN: null-ptr-deref in sg\_copy\_buffer+0x138/0x240 lib/scatterlist.c:974
Write of size 4 at addr 0000000000000010 by task syz-executor.1/22789

CPU: 1 PID: 22789 Comm: syz-executor.1 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
 \_\_kasan\_report mm/kasan/report.c:446 \[inline\]
 kasan\_report.cold.14+0x112/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+0x3b/0x60 mm/kasan/shadow.c:66
 memcpy include/linux/fortify-string.h:191 \[inline\]
 sg\_copy\_buffer+0x138/0x240 lib/scatterlist.c:974
 do\_dout\_fetch drivers/scsi/scsi\_debug.c:2954 \[inline\]
 do\_dout\_fetch drivers/scsi/scsi\_debug.c:2946 \[inline\]
 resp\_verify+0x49e/0x930 drivers/scsi/scsi\_debug.c:4276
 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
 blk\_execute\_rq+0xdb/0x360 block/blk-exec.c:102
 sg\_scsi\_ioctl drivers/scsi/scsi\_ioctl.c:621 \[inline\]
 scsi\_ioctl+0x8bb/0x15c0 drivers/scsi/scsi\_ioctl.c:930
 sg\_ioctl\_common+0x172d/0x2710 drivers/scsi/sg.c:1112
 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: \>= c3e2fe9222d428f115baeba2f6b3637b3aa444cd, \< aa1f912712a109b6306746133de7e5343f016b26; \>= c3e2fe9222d428f115baeba2f6b3637b3aa444cd, \< 47d11d35203b0aa13533634e270fe2c3610e531b; \>= c3e2fe9222d428f115baeba2f6b3637b3aa444cd, \< 3344b58b53a76199dae48faa396e9fc37bf86992 (cvelist)
- Linux: 5.8 (cvelist)

## Mitigation

- Upgrade Linux to 3344b58b53a76199dae48faa396e9fc37bf86992 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-47578. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2021-47578.md
Affected: Linux >= c3e2fe9222d428f115baeba2f6b3637b3aa444cd, < aa1f912712a109b6306746133de7e5343f016b26; >= c3e2fe9222d428f115baeba2f6b3637b3aa444cd, < 47d11d35203b0aa13533634e270fe2c3610e531b; >= c3e2fe9222d428f115baeba2f6b3637b3aa444cd, < 3344b58b53a76199dae48faa396e9fc37bf86992; Linux 5.8
Fixed in: Linux 47d11d35203b0aa13533634e270fe2c3610e531b, Linux 3344b58b53a76199dae48faa396e9fc37bf86992

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-47578 being exploited?

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

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

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

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

Linux \>= c3e2fe9222d428f115baeba2f6b3637b3aa444cd, \< aa1f912712a109b6306746133de7e5343f016b26; \>= c3e2fe9222d428f115baeba2f6b3637b3aa444cd, \< 47d11d35203b0aa13533634e270fe2c3610e531b; \>= c3e2fe9222d428f115baeba2f6b3637b3aa444cd, \< 3344b58b53a76199dae48faa396e9fc37bf86992; Linux 5.8.

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

Yes. Fixed in Linux 47d11d35203b0aa13533634e270fe2c3610e531b, Linux 3344b58b53a76199dae48faa396e9fc37bf86992. Upgrade Linux to 3344b58b53a76199dae48faa396e9fc37bf86992 or later.

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

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/aa1f912712a109b6306746133de7e5343f016b26>
- patch: <https://git.kernel.org/stable/c/47d11d35203b0aa13533634e270fe2c3610e531b>
- patch: <https://git.kernel.org/stable/c/3344b58b53a76199dae48faa396e9fc37bf86992>

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

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