Bug 2301539 (CVE-2024-42161) - CVE-2024-42161 kernel: bpf: Avoid uninitialized value in BPF_CORE_READ_BITFIELD
Summary: CVE-2024-42161 kernel: bpf: Avoid uninitialized value in BPF_CORE_READ_BITFIELD
Keywords:
Status: NEW
Alias: CVE-2024-42161
Product: Security Response
Classification: Other
Component: vulnerability
Version: unspecified
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Product Security DevOps Team
QA Contact:
URL:
Whiteboard:
Depends On: 2302032
Blocks:
TreeView+ depends on / blocked
 
Reported: 2024-07-30 09:08 UTC by OSIDB Bzimport
Modified: 2024-09-24 13:48 UTC (History)
4 users (show)

Fixed In Version: kernel 5.10.222, kernel 5.15.163, kernel 6.1.98, kernel 6.6.39, kernel 6.9.9, kernel 6.10
Clone Of:
Environment:
Last Closed:
Embargoed:


Attachments (Terms of Use)

Description OSIDB Bzimport 2024-07-30 09:08:43 UTC
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.

Comment 1 Mauro Matteo Cascella 2024-07-31 11:30:19 UTC
Upstream advisory:
https://lore.kernel.org/linux-cve-announce/2024073036-CVE-2024-42161-7104@gregkh/T

Comment 2 Mauro Matteo Cascella 2024-07-31 11:30:41 UTC
Created kernel tracking bugs for this issue:

Affects: fedora-all [bug 2302032]


Note You need to log in before you can comment on or make changes to this bug.