In the Linux kernel, the following vulnerability has been resolved:
bpf: Fix a kernel verifier crash in stacksafe()
Daniel Hodges reported a kernel verifier crash when playing with sched-ext. Further investigation shows that the crash is due to invalid memory access in stacksafe(). More specifically, it is the following code:
if (exact != NOT_EXACT &&
old->stack[spi].slot_type[i % BPF_REG_SIZE] !=
cur->stack[spi].slot_type[i % BPF_REG_SIZE])
return false;
The 'i' iterates old->allocatedstack. If cur->allocatedstack < old->allocated_stack the out-of-bound access will happen.
To fix the issue add 'i >= cur->allocatedstack' check such that if the condition is true, stacksafe() should fail. Otherwise, cur->stack[spi].slottype[i % BPFREGSIZE] memory access is legal.
[
{
"deprecated": false,
"signature_version": "v1",
"digest": {
"threshold": 0.9,
"line_hashes": [
"322198325282551150497597915949366478266",
"35115837087594568153765789816046257035",
"254103083496380533287246688785723376362",
"334916770808929024351956086150989644671",
"233574285408353597226430589877391362589"
]
},
"id": "CVE-2024-45020-722d608d",
"signature_type": "Line",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@bed2eb964c70b780fb55925892a74f26cb590b25",
"target": {
"file": "kernel/bpf/verifier.c"
}
},
{
"deprecated": false,
"signature_version": "v1",
"digest": {
"function_hash": "77733944842172065930539484698791680204",
"length": 2400.0
},
"id": "CVE-2024-45020-74fc0fe5",
"signature_type": "Function",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@6e3987ac310c74bb4dd6a2fa8e46702fe505fb2b",
"target": {
"file": "kernel/bpf/verifier.c",
"function": "stacksafe"
}
},
{
"deprecated": false,
"signature_version": "v1",
"digest": {
"threshold": 0.9,
"line_hashes": [
"322198325282551150497597915949366478266",
"35115837087594568153765789816046257035",
"254103083496380533287246688785723376362",
"334916770808929024351956086150989644671",
"233574285408353597226430589877391362589"
]
},
"id": "CVE-2024-45020-e18ed6f6",
"signature_type": "Line",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@6e3987ac310c74bb4dd6a2fa8e46702fe505fb2b",
"target": {
"file": "kernel/bpf/verifier.c"
}
},
{
"deprecated": false,
"signature_version": "v1",
"digest": {
"function_hash": "77733944842172065930539484698791680204",
"length": 2400.0
},
"id": "CVE-2024-45020-f4d65afd",
"signature_type": "Function",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@bed2eb964c70b780fb55925892a74f26cb590b25",
"target": {
"file": "kernel/bpf/verifier.c",
"function": "stacksafe"
}
}
]