In the Linux kernel, the following vulnerability has been resolved:
bpf: Avoid uninitialized value in BPFCOREREAD_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 BPFCREREADBITFIELD macro, defined in bpfcore_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 _builtinpreservefieldinfo returns unexpected values for BPFFIELDBYTE_SIZE.
Tested in bpf-next master. No regressions.
[
{
"signature_version": "v1",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@009367099eb61a4fc2af44d4eb06b6b4de7de6db",
"signature_type": "Line",
"target": {
"file": "tools/lib/bpf/bpf_core_read.h"
},
"id": "CVE-2024-42161-03ea63cb",
"digest": {
"line_hashes": [
"116924010327327588041379783291265147522",
"192474841647757994425981131489686784276",
"53191107355095402153989474593829502842",
"124065026273866157315603429585423062823"
],
"threshold": 0.9
},
"deprecated": false
},
{
"signature_version": "v1",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@7e5471b5efebc30dd0bc035cda86693a5c73d45f",
"signature_type": "Line",
"target": {
"file": "tools/lib/bpf/bpf_core_read.h"
},
"id": "CVE-2024-42161-748aa106",
"digest": {
"line_hashes": [
"116924010327327588041379783291265147522",
"192474841647757994425981131489686784276",
"53191107355095402153989474593829502842",
"124065026273866157315603429585423062823"
],
"threshold": 0.9
},
"deprecated": false
},
{
"signature_version": "v1",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@3364c2ed1c241989847f19cf83e3db903ce689e3",
"signature_type": "Line",
"target": {
"file": "tools/lib/bpf/bpf_core_read.h"
},
"id": "CVE-2024-42161-779aba86",
"digest": {
"line_hashes": [
"116924010327327588041379783291265147522",
"192474841647757994425981131489686784276",
"53191107355095402153989474593829502842",
"124065026273866157315603429585423062823"
],
"threshold": 0.9
},
"deprecated": false
},
{
"signature_version": "v1",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b694989bb13ed5f166e633faa1eb0f21c6d261a6",
"signature_type": "Line",
"target": {
"file": "tools/lib/bpf/bpf_core_read.h"
},
"id": "CVE-2024-42161-7b92c382",
"digest": {
"line_hashes": [
"116924010327327588041379783291265147522",
"192474841647757994425981131489686784276",
"53191107355095402153989474593829502842",
"124065026273866157315603429585423062823"
],
"threshold": 0.9
},
"deprecated": false
},
{
"signature_version": "v1",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@ff941a8449e712eaf7efca1a13bfb9afd3d99fc2",
"signature_type": "Line",
"target": {
"file": "tools/lib/bpf/bpf_core_read.h"
},
"id": "CVE-2024-42161-a8efcb72",
"digest": {
"line_hashes": [
"116924010327327588041379783291265147522",
"192474841647757994425981131489686784276",
"53191107355095402153989474593829502842",
"124065026273866157315603429585423062823"
],
"threshold": 0.9
},
"deprecated": false
}
]