CVE-2024-42161 bpf: Avoid uninitialized value in BPF_CORE_READ_BITFIELD
A missing default case in a BPF macro could lead to using uninitialized memory, potentially causing undefined behavior or information leaks.
- Exploited in the wild
- Not known
- Login needed
- An administrator
- Attackable
- Local or same network only
- Victim action needed
- Not needed
- Fix
- Available
What is CVE-2024-42161?
CVE-2024-42161 is a medium-severity vulnerability in Linux kernel, published on 30 Jul 2024. It can only be exploited from the same machine or local network, with no action from the victim.
Official description
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.
Weakness: CWE-908
Which versions are affected by CVE-2024-42161?
It affects 1 product.
Products include Linux kernel.
How do I fix CVE-2024-42161?
Apply the vendor's patch.
Is CVE-2024-42161 being exploited?
There is no known exploitation of CVE-2024-42161 in the wild and no public exploit code.
Other vulnerabilities in Linux kernel
Sources
Also known as AZL-47409, AZL-47412, BELL-CVE-2024-42161, DEBIAN-CVE-2024-42161, GHSA-5hjg-m862-88fc, UBUNTU-CVE-2024-42161.