Skip to main content

CVE-2024-50254: Vulnerability in Linux Linux

Medium
VulnerabilityCVE-2024-50254cvecve-2024-50254
Published: Sat Nov 09 2024 (11/09/2024, 10:15:07 UTC)
Source: CVE
Vendor/Project: Linux
Product: Linux

Description

In the Linux kernel, the following vulnerability has been resolved: bpf: Free dynamically allocated bits in bpf_iter_bits_destroy() bpf_iter_bits_destroy() uses "kit->nr_bits <= 64" to check whether the bits are dynamically allocated. However, the check is incorrect and may cause a kmemleak as shown below: unreferenced object 0xffff88812628c8c0 (size 32): comm "swapper/0", pid 1, jiffies 4294727320 hex dump (first 32 bytes): b0 c1 55 f5 81 88 ff ff f0 f0 f0 f0 f0 f0 f0 f0 ..U........... f0 f0 f0 f0 f0 f0 f0 f0 00 00 00 00 00 00 00 00 .............. backtrace (crc 781e32cc): [<00000000c452b4ab>] kmemleak_alloc+0x4b/0x80 [<0000000004e09f80>] __kmalloc_node_noprof+0x480/0x5c0 [<00000000597124d6>] __alloc.isra.0+0x89/0xb0 [<000000004ebfffcd>] alloc_bulk+0x2af/0x720 [<00000000d9c10145>] prefill_mem_cache+0x7f/0xb0 [<00000000ff9738ff>] bpf_mem_alloc_init+0x3e2/0x610 [<000000008b616eac>] bpf_global_ma_init+0x19/0x30 [<00000000fc473efc>] do_one_initcall+0xd3/0x3c0 [<00000000ec81498c>] kernel_init_freeable+0x66a/0x940 [<00000000b119f72f>] kernel_init+0x20/0x160 [<00000000f11ac9a7>] ret_from_fork+0x3c/0x70 [<0000000004671da4>] ret_from_fork_asm+0x1a/0x30 That is because nr_bits will be set as zero in bpf_iter_bits_next() after all bits have been iterated. Fix the issue by setting kit->bit to kit->nr_bits instead of setting kit->nr_bits to zero when the iteration completes in bpf_iter_bits_next(). In addition, use "!nr_bits || bits >= nr_bits" to check whether the iteration is complete and still use "nr_bits > 64" to indicate whether bits are dynamically allocated. The "!nr_bits" check is necessary because bpf_iter_bits_new() may fail before setting kit->nr_bits, and this condition will stop the iteration early instead of accessing the zeroed or freed kit->bits. Considering the initial value of kit->bits is -1 and the type of kit->nr_bits is unsigned int, change the type of kit->nr_bits to int. The potential overflow problem will be handled in the following patch.

AI-Powered Analysis

AILast updated: 06/28/2025, 13:27:16 UTC

Technical Analysis

CVE-2024-50254 is a vulnerability identified in the Linux kernel's BPF (Berkeley Packet Filter) subsystem, specifically within the bpf_iter_bits_destroy() function. The vulnerability arises due to an incorrect check on whether dynamically allocated bits should be freed. The function uses the condition "kit->nr_bits <= 64" to determine if bits are dynamically allocated, but this check is flawed. During iteration, the variable nr_bits is set to zero after all bits have been iterated, which causes the function to skip freeing dynamically allocated memory, leading to a kernel memory leak (kmemleak). The root cause is that the iteration completion check incorrectly zeroes nr_bits instead of properly setting the bit index, resulting in unreferenced kernel memory objects that are not freed. The vulnerability is subtle and relates to the internal memory management of BPF iterators, which are used for efficient packet filtering and tracing in the Linux kernel. The fix involves changing the iteration logic to set kit->bit to kit->nr_bits instead of zeroing nr_bits, adjusting the condition to check for iteration completion with "!nr_bits || bits >= nr_bits", and changing the type of kit->nr_bits from unsigned int to int to handle potential overflow issues. This patch ensures that dynamically allocated bits are correctly freed, preventing memory leaks in the kernel. Although this vulnerability does not directly lead to code execution or privilege escalation, the memory leak could degrade system stability and reliability over time, especially in systems heavily utilizing BPF features.

Potential Impact

For European organizations, the impact of CVE-2024-50254 primarily concerns system stability and reliability rather than immediate security breaches. Organizations relying on Linux servers, especially those using advanced networking, tracing, or security monitoring tools leveraging BPF, may experience kernel memory leaks that could lead to increased memory consumption, degraded performance, or system crashes if exploited over time. This is particularly relevant for data centers, cloud providers, telecom operators, and enterprises running container orchestration platforms like Kubernetes that use BPF for networking and observability. While the vulnerability does not appear to allow direct exploitation for privilege escalation or remote code execution, the memory leak could be leveraged in complex attack chains or cause denial of service conditions. European organizations with critical infrastructure or high-availability requirements should be aware of this risk. The absence of known exploits in the wild reduces immediate threat levels, but proactive patching is recommended to maintain kernel integrity and prevent potential stability issues.

Mitigation Recommendations

To mitigate CVE-2024-50254, European organizations should: 1) Apply the latest Linux kernel patches that address this vulnerability as soon as they become available from trusted sources or vendor distributions. 2) Monitor kernel memory usage and kmemleak reports on systems heavily utilizing BPF to detect abnormal memory consumption patterns. 3) Limit the use of untrusted or unnecessary BPF programs and iterators, especially in multi-tenant or shared environments, to reduce exposure. 4) Employ kernel hardening and runtime integrity monitoring tools that can detect anomalous kernel memory behavior. 5) Coordinate with Linux distribution vendors and cloud providers to ensure timely updates and vulnerability disclosures. 6) For critical systems, consider implementing kernel live patching solutions to apply fixes without downtime. These steps go beyond generic advice by focusing on monitoring and operational controls specific to BPF usage and kernel memory management.

Need more detailed analysis?Get Pro

Technical Details

Data Version
5.1
Assigner Short Name
Linux
Date Reserved
2024-10-21T19:36:19.980Z
Cisa Enriched
false
Cvss Version
null
State
PUBLISHED

Threat ID: 682d9824c4522896dcbdf662

Added to database: 5/21/2025, 9:08:52 AM

Last enriched: 6/28/2025, 1:27:16 PM

Last updated: 8/16/2025, 3:37:39 AM

Views: 13

Actions

PRO

Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.

Please log in to the Console to use AI analysis features.

Need enhanced features?

Contact root@offseq.com for Pro access with improved analysis and higher rate limits.

Latest Threats