CVE-2021-47585: Vulnerability in Linux Linux
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 }
AI Analysis
Technical Summary
CVE-2021-47585 is a memory leak vulnerability identified in the Linux kernel's Btrfs filesystem implementation, specifically within the __add_inode_ref() function. The vulnerability arises due to improper memory management where allocated memory for the variable victim_name is not freed under certain error conditions. The function allocates memory twice for victim_name using kmalloc(), but in the second allocation scenario (around line 1169), if the call to backref_in_log() returns a negative value (indicating an error), the function returns immediately without freeing the allocated memory. This results in a memory leak. The first allocation scenario correctly frees the memory upon error, but the second does not, leading to inconsistent handling. The memory leak could cause the kernel's memory usage to grow unnecessarily over time, potentially leading to resource exhaustion. Although this vulnerability does not directly allow code execution or privilege escalation, the leak could degrade system stability and availability, especially on systems with heavy Btrfs usage or under repeated error conditions triggering this code path. The vulnerability affects Linux kernel versions identified by the commit hash d3316c8233bb05e0dd855d30aac347bb8ad76ee4 and was publicly disclosed in June 2024. No known exploits are reported in the wild, and no CVSS score has been assigned yet. The fix involves adding a kfree() call to properly release victim_name memory before returning on error in the second allocation path.
Potential Impact
For European organizations, the impact of CVE-2021-47585 primarily concerns system stability and availability. Organizations relying on Linux servers with Btrfs filesystems—commonly used for advanced storage features like snapshots and checksumming—may experience gradual memory leaks leading to increased memory consumption. Over time, this can cause system slowdowns, crashes, or forced reboots, disrupting critical services. This is particularly relevant for data centers, cloud providers, and enterprises using Btrfs for storage management. While the vulnerability does not directly compromise confidentiality or integrity, the availability impact can affect business continuity and service reliability. Systems under heavy load or with frequent filesystem operations invoking __add_inode_ref() are at higher risk. Since no authentication or user interaction is required to trigger this leak, any process or kernel operation that encounters the error path can cause the leak, increasing the attack surface. European organizations with large-scale Linux deployments should be aware of this risk, especially in sectors like finance, telecommunications, and government where uptime is critical.
Mitigation Recommendations
To mitigate CVE-2021-47585, European organizations should prioritize updating their Linux kernel to a version that includes the patch fixing the memory leak in __add_inode_ref(). If immediate patching is not feasible, monitoring system memory usage closely on Btrfs-enabled systems is recommended to detect abnormal growth indicative of leaks. Administrators should audit and limit the use of Btrfs where possible or consider alternative filesystems if stability is paramount and patching is delayed. Additionally, implementing kernel memory leak detection tools and enabling kernel debugging features can help identify and diagnose leaks early. For environments using automated configuration management, integrating kernel updates into regular maintenance cycles will reduce exposure. Finally, organizations should review logs for repeated errors from backref_in_log() calls, as these may signal conditions triggering the leak, allowing proactive intervention.
Affected Countries
Germany, France, United Kingdom, Netherlands, Sweden, Finland, Poland, Italy
CVE-2021-47585: Vulnerability in Linux Linux
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 }
AI-Powered Analysis
Technical Analysis
CVE-2021-47585 is a memory leak vulnerability identified in the Linux kernel's Btrfs filesystem implementation, specifically within the __add_inode_ref() function. The vulnerability arises due to improper memory management where allocated memory for the variable victim_name is not freed under certain error conditions. The function allocates memory twice for victim_name using kmalloc(), but in the second allocation scenario (around line 1169), if the call to backref_in_log() returns a negative value (indicating an error), the function returns immediately without freeing the allocated memory. This results in a memory leak. The first allocation scenario correctly frees the memory upon error, but the second does not, leading to inconsistent handling. The memory leak could cause the kernel's memory usage to grow unnecessarily over time, potentially leading to resource exhaustion. Although this vulnerability does not directly allow code execution or privilege escalation, the leak could degrade system stability and availability, especially on systems with heavy Btrfs usage or under repeated error conditions triggering this code path. The vulnerability affects Linux kernel versions identified by the commit hash d3316c8233bb05e0dd855d30aac347bb8ad76ee4 and was publicly disclosed in June 2024. No known exploits are reported in the wild, and no CVSS score has been assigned yet. The fix involves adding a kfree() call to properly release victim_name memory before returning on error in the second allocation path.
Potential Impact
For European organizations, the impact of CVE-2021-47585 primarily concerns system stability and availability. Organizations relying on Linux servers with Btrfs filesystems—commonly used for advanced storage features like snapshots and checksumming—may experience gradual memory leaks leading to increased memory consumption. Over time, this can cause system slowdowns, crashes, or forced reboots, disrupting critical services. This is particularly relevant for data centers, cloud providers, and enterprises using Btrfs for storage management. While the vulnerability does not directly compromise confidentiality or integrity, the availability impact can affect business continuity and service reliability. Systems under heavy load or with frequent filesystem operations invoking __add_inode_ref() are at higher risk. Since no authentication or user interaction is required to trigger this leak, any process or kernel operation that encounters the error path can cause the leak, increasing the attack surface. European organizations with large-scale Linux deployments should be aware of this risk, especially in sectors like finance, telecommunications, and government where uptime is critical.
Mitigation Recommendations
To mitigate CVE-2021-47585, European organizations should prioritize updating their Linux kernel to a version that includes the patch fixing the memory leak in __add_inode_ref(). If immediate patching is not feasible, monitoring system memory usage closely on Btrfs-enabled systems is recommended to detect abnormal growth indicative of leaks. Administrators should audit and limit the use of Btrfs where possible or consider alternative filesystems if stability is paramount and patching is delayed. Additionally, implementing kernel memory leak detection tools and enabling kernel debugging features can help identify and diagnose leaks early. For environments using automated configuration management, integrating kernel updates into regular maintenance cycles will reduce exposure. Finally, organizations should review logs for repeated errors from backref_in_log() calls, as these may signal conditions triggering the leak, allowing proactive intervention.
Affected Countries
For access to advanced analysis and higher rate limits, contact root@offseq.com
Technical Details
- Data Version
- 5.1
- Assigner Short Name
- Linux
- Date Reserved
- 2024-05-24T15:11:00.731Z
- Cisa Enriched
- true
- Cvss Version
- null
- State
- PUBLISHED
Threat ID: 682d9833c4522896dcbe951d
Added to database: 5/21/2025, 9:09:07 AM
Last enriched: 6/30/2025, 2:57:21 PM
Last updated: 8/3/2025, 12:51:14 AM
Views: 14
Related Threats
CVE-2025-8958: Stack-based Buffer Overflow in Tenda TX3
HighCVE-2025-8957: SQL Injection in Campcodes Online Flight Booking Management System
MediumCVE-2025-54707: CWE-89 Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') in RealMag777 MDTF
CriticalCVE-2025-54706: CWE-79 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') in Noor Alam Magical Posts Display
MediumCVE-2025-54705: CWE-862 Missing Authorization in magepeopleteam WpEvently
MediumActions
Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.
External Links
Need enhanced features?
Contact root@offseq.com for Pro access with improved analysis and higher rate limits.