CVE-2021-47585
btrfs: fix memory leak in __add_inode_ref()
Mitigation
- No fix listed yet: follow the vendor advisory.
Who should check
- Anyone running Linux >= d3316c8233bb05e0dd855d30aac347bb8ad76ee4, < 005d9292b5b2e71a009f911bd85d755009b37242; >= d3316c8233bb05e0dd855d30aac347bb8ad76ee4, < 493ff661d434d6bdf02e3a21adae04d7a0b4265d; >= d3316c8233bb05e0dd855d30aac347bb8ad76ee4, < f35838a6930296fc1988764cfa54cb3f705c0665
- Anyone running Linux 5.5
Vulnerability facts
- Affected
- Linux >= d3316c8233bb05e0dd855d30aac347bb8ad76ee4, < 005d9292b5b2e71a009f911bd85d755009b37242; >= d3316c8233bb05e0dd855d30aac347bb8ad76ee4, < 493ff661d434d6bdf02e3a21adae04d7a0b4265d; >= d3316c8233bb05e0dd855d30aac347bb8ad76ee4, < f35838a6930296fc1988764cfa54cb3f705c0665; Linux 5.5
- Fixed in
- Linux 005d9292b5b2e71a009f911bd85d755009b37242, Linux 493ff661d434d6bdf02e3a21adae04d7a0b4265d
- Exploited in the wild
- Not in CISA KEV
- Public exploit / PoC
- None known
- Remote exploitation
- Not remotely exploitable (local or adjacent access needed)
- CVSS
- 5.5 (v3.1, NVD)CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:HOpen in CVSS calculator
Show all 8 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
- EPSS
- 0.30% chance of exploitation in 30 days (percentile 16, 2026-11-26)
- CWE
- CWE-401
- Modified
Description
In the Linux kernel, the following vulnerability has been resolved: btrfs: fix memory leak in __add_inode_ref() Line 1169 (#3) allocates a memory chunk for victim_name by kmalloc(), but when the function returns in line 1184 (#4) victim_name allocated by line 1169 (#3) is not freed, which will lead to a memory leak. There is a similar snippet of code in this function as allocating a memory chunk for victim_name in line 1104 (#1) as well as releasing the memory in line 1116 (#2). We should kfree() victim_name when the return value of backref_in_log() is less than zero and before the function returns in line 1184 (#4). 1057 static inline int __add_inode_ref(struct btrfs_trans_handle *trans, 1058 struct btrfs_root *root, 1059 struct btrfs_path *path, 1060 struct btrfs_root *log_root, 1061 struct btrfs_inode *dir, 1062 struct btrfs_inode *inode, 1063 u64 inode_objectid, u64 parent_objectid, 1064 u64 ref_index, char *name, int namelen, 1065 int *search_done) 1066 { 1104 victim_name = kmalloc(victim_name_len, GFP_NOFS); // #1: kmalloc (victim_name-1) 1105 if (!victim_name) 1106 return -ENOMEM; 1112 ret = backref_in_log(log_root, &search_key, 1113 parent_objectid, victim_name, 1114 victim_name_len); 1115 if (ret < 0) { 1116 kfree(victim_name); // #2: kfree (victim_name-1) 1117 return ret; 1118 } else if (!ret) { 1169 victim_name = kmalloc(victim_name_len, GFP_NOFS); // #3: kmalloc (victim_name-2) 1170 if (!victim_name) 1171 return -ENOMEM; 1180 ret = backref_in_log(log_root, &search_key, 1181 parent_objectid, victim_name, 1182 victim_name_len); 1183 if (ret < 0) { 1184 return ret; // #4: missing kfree (victim_name-2) 1185 } else if (!ret) { 1241 return 0; 1242 }
Affected and fixed versions
| Package / product | Affected | Fixed | Source |
|---|---|---|---|
| Linux | >= d3316c8233bb05e0dd855d30aac347bb8ad76ee4, < 005d9292b5b2e71a009f911bd85d755009b37242; >= d3316c8233bb05e0dd855d30aac347bb8ad76ee4, < 493ff661d434d6bdf02e3a21adae04d7a0b4265d; >= d3316c8233bb05e0dd855d30aac347bb8ad76ee4, < f35838a6930296fc1988764cfa54cb3f705c0665 | — | cvelist |
| Linux | 5.5 | — | cvelist |
Check your systems with an agent
Paste this into Claude Code, Cursor or another coding agent. It only reads; it changes nothing.
Check whether anything I run is affected by CVE-2021-47585. Work read-only: do not install, upgrade, delete or change anything. Details: https://flawdb.com/CVE-2021-47585.md Affected: Linux >= d3316c8233bb05e0dd855d30aac347bb8ad76ee4, < 005d9292b5b2e71a009f911bd85d755009b37242; >= d3316c8233bb05e0dd855d30aac347bb8ad76ee4, < 493ff661d434d6bdf02e3a21adae04d7a0b4265d; >= d3316c8233bb05e0dd855d30aac347bb8ad76ee4, < f35838a6930296fc1988764cfa54cb3f705c0665; Linux 5.5 Fixed in: Linux 005d9292b5b2e71a009f911bd85d755009b37242, Linux 493ff661d434d6bdf02e3a21adae04d7a0b4265d 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.
References
FAQ
Is CVE-2021-47585 being exploited?
There is no confirmed exploitation: CVE-2021-47585 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.30% chance of exploitation in the next 30 days (as of 2026-11-26).
How serious is CVE-2021-47585?
Medium: CVSS 5.5 (v3.1, scored by NVD). Not remotely exploitable (local or adjacent access needed).
Which versions are affected by CVE-2021-47585?
Linux >= d3316c8233bb05e0dd855d30aac347bb8ad76ee4, < 005d9292b5b2e71a009f911bd85d755009b37242; >= d3316c8233bb05e0dd855d30aac347bb8ad76ee4, < 493ff661d434d6bdf02e3a21adae04d7a0b4265d; >= d3316c8233bb05e0dd855d30aac347bb8ad76ee4, < f35838a6930296fc1988764cfa54cb3f705c0665; Linux 5.5.
Is there a fix for CVE-2021-47585?
Yes. Fixed in Linux 005d9292b5b2e71a009f911bd85d755009b37242, Linux 493ff661d434d6bdf02e3a21adae04d7a0b4265d. No fix listed yet: follow the vendor advisory.
How do I check if I'm affected by CVE-2021-47585?
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.