CVE-2024-42161·Kernel vulnerability
In the Linux kernel, the following vulnerability has been resolved: bpf: Avoid uninitialized value in BPF_CORE_READ_BITFIELD [Changes from V1: - Use a default branch in the switch statement to initialize `val'.] GCC warns that `val' may be used uninitialized in the BPF_CRE_READ_BITFIELD macro, defined in bpf_core_read.h as: [...] unsigned long long val; \ [...] \ switch (__CORE_RELO(s, field, BYTE_SIZE)) { \ case 1: val = *(const unsigned char *)p; break; \ case 2: val = *(const unsigned short *)p; break; \ case 4: val = *(const unsigned int *)p; break; \ case 8: val = *(const unsigned long long *)p; break; \ } \ [...] val; \ } \ This patch adds a default entry in the switch statement that sets `val' to zero in order to avoid the warning, and random values to be used in case __builtin_preserve_field_info returns unexpected values for BPF_FIELD_BYTE_SIZE. Tested in bpf-next master. No regressions.
- Severity
- medium
- Software
- Kernel
- Fixed in
- 6.9.9
- Published
- 2024-07-30
Affected versions
From: 6.7
Until: 6.9.9
Fixed in: 6.9.9
How to fix this CVE
Update your Linux kernel to version 6.9.9 or later to resolve this uninitialized variable vulnerability in the BPF_CORE_READ_BITFIELD macro. This fix prevents potential use of uninitialized memory values that could lead to information disclosure or system instability in eBPF programs. Apply the patch immediately if your systems are running kernel versions 6.7 through 6.9.8.
sudo dnf update kernel kernel-develDefensia detects this vulnerability
How to check if you are affected
- Check your kernel version: uname -r | grep -E '^(6\.[789]|6\.9\.[0-8])'
- Verify the vulnerable BPF_CORE_READ_BITFIELD macro is in use: grep -r 'BPF_CORE_READ_BITFIELD' /usr/include/bpf/ 2>/dev/null || echo 'BPF headers not found'
- Search for eBPF program loading attempts in system logs: journalctl -u systemd-bpfd -n 1000 2>/dev/null || dmesg | grep -i 'bpf'
- Confirm patch installation by checking if kernel version is 6.9.9 or later: uname -r | awk -F. '{if ($1==6 && $2==9 && $3>=9) print "PATCHED"; else print "VULNERABLE"}'
FAQ
What is CVE-2024-42161?
CVE-2024-42161 is a medium-severity vulnerability in the Linux kernel where the BPF_CORE_READ_BITFIELD macro could use uninitialized memory values due to missing default handling in a switch statement. This can result in information disclosure or unpredictable behavior in eBPF programs when the macro receives unexpected byte size values.
Is CVE-2024-42161 being actively exploited?
No, CVE-2024-42161 is not listed in the CISA Known Exploited Vulnerabilities catalog and has no publicly available exploits. However, it should still be patched to prevent potential future exploitation and to ensure eBPF program stability.
What versions of Kernel are affected by CVE-2024-42161?
Linux kernel versions 6.7 through 6.9.8 are affected. The vulnerability was resolved in kernel 6.9.9 and later stable releases.
How do I check if my server is vulnerable to CVE-2024-42161?
Run 'uname -r' to display your kernel version. If it shows a version between 6.7 and 6.9.8 (inclusive), your system is vulnerable. For example, if you see '6.9.5-generic', you need to update.
Does Defensia detect CVE-2024-42161?
Yes — Defensia's CVE advisory scanner compares installed package versions against the NVD database. If the Linux kernel is installed on a monitored server, CVE-2024-42161 will appear in your dashboard with remediation steps.
Related Kernel CVEs
References
- https://git.kernel.org/stable/c/009367099eb61a4fc2af44d4eb06b6b4de7de6db
- https://git.kernel.org/stable/c/3364c2ed1c241989847f19cf83e3db903ce689e3
- https://git.kernel.org/stable/c/7e5471b5efebc30dd0bc035cda86693a5c73d45f
- https://git.kernel.org/stable/c/a21d76bd0b0d39518e9a4c19f6cf7c042a974aff
- https://git.kernel.org/stable/c/b694989bb13ed5f166e633faa1eb0f21c6d261a6
Track CVEs across your fleet automatically
Defensia scans your Linux servers and tells you exactly which ones are running vulnerable versions — including CVE-2024-42161. Free for 1 server.
Get started free