CVE-2021-47585·Kernel vulnerability
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 }
- Severity
- medium
- Software
- Kernel
- Fixed in
- 5.15.11
- Published
- 2024-06-19
Affected versions
From: 5.11
Until: 5.15.11
Fixed in: 5.15.11
How to fix this CVE
Update the Linux kernel to version 5.15.11 or later to patch a memory leak in the Btrfs filesystem's inode reference handling. This vulnerability causes kernel memory to not be properly freed during specific error conditions, potentially leading to denial of service over time. Systems running Kernel versions 5.11 through 5.15.10 should prioritize this update.
sudo dnf update kernel kernel-develDefensia detects this vulnerability
How to check if you are affected
- Step 1: Check your kernel version with `uname -r` and compare against the affected range (5.11 to 5.15.10)
- Step 2: Verify Btrfs is in use on your system by running `mount | grep btrfs` to identify affected filesystems
- Step 3: Monitor system memory usage over time with `free -h` or `watch -n 5 free -h` to detect gradual memory depletion patterns
- Step 4: After applying the update, confirm the new kernel version loaded by running `uname -r` and rebooting if necessary with `sudo reboot`
FAQ
What is CVE-2021-47585?
A memory leak in the Linux kernel's Btrfs filesystem implementation where the __add_inode_ref() function fails to release allocated memory when certain error conditions occur during inode reference processing, potentially exhausting system memory.
Is CVE-2021-47585 being actively exploited?
No, this vulnerability is not listed in CISA's Known Exploited Vulnerabilities catalog and no public exploits are currently available. It requires local filesystem operations and cannot be triggered remotely.
What versions of Kernel are affected by CVE-2021-47585?
Linux kernel versions 5.11 through 5.15.10 are vulnerable. The vulnerability was fixed in version 5.15.11 and later.
How do I check if my server is vulnerable to CVE-2021-47585?
Run `uname -r` to display your kernel version. If it shows a version between 5.11 and 5.15.10 and you use Btrfs (check with `mount | grep btrfs`), your system is vulnerable.
Does Defensia detect CVE-2021-47585?
Yes — Defensia's CVE advisory scanner compares installed package versions against the NVD database. If Kernel is installed on a monitored server, CVE-2021-47585 will appear in your dashboard with remediation steps.
Related Kernel CVEs
References
- https://git.kernel.org/stable/c/005d9292b5b2e71a009f911bd85d755009b37242
- https://git.kernel.org/stable/c/493ff661d434d6bdf02e3a21adae04d7a0b4265d
- https://git.kernel.org/stable/c/f35838a6930296fc1988764cfa54cb3f705c0665
- https://git.kernel.org/stable/c/005d9292b5b2e71a009f911bd85d755009b37242
- https://git.kernel.org/stable/c/493ff661d434d6bdf02e3a21adae04d7a0b4265d
Track CVEs across your fleet automatically
Defensia scans your Linux servers and tells you exactly which ones are running vulnerable versions — including CVE-2021-47585. Free for 1 server.
Get started free