In the Linux kernel, the following vulnerability has been resolved:
bpf: correctly handle malformed BPFCORETYPEIDLOCAL relos
In case of malformed relocation record of kind BPFCORETYPEIDLOCAL referencing a non-existing BTF type, function bpfcorecalcreloinsn would cause a null pointer deference.
Fix this by adding a proper check upper in call stack, as malformed relocation records could be passed from user space.
Simplest reproducer is a program:
r0 = 0
exit
With a single relocation record:
.insn_off = 0, /* patch first instruction */
.type_id = 100500, /* this type id does not exist */
.access_str_off = 6, /* offset of string "0" */
.kind = BPF_CORE_TYPE_ID_LOCAL,
See the link for original reproducer or next commit for a test case.
{
"cna_assigner": "Linux",
"osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/49xxx/CVE-2024-49850.json"
}"https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2024-49850.json"
[
{
"signature_version": "v1",
"target": {
"file": "kernel/bpf/btf.c",
"function": "bpf_core_apply"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@e7e9c5b2dda29067332df2a85b0141a92b41f218",
"deprecated": false,
"digest": {
"function_hash": "57778576498914627853206264534595888255",
"length": 1508.0
},
"id": "CVE-2024-49850-31e891fd",
"signature_type": "Function"
},
{
"signature_version": "v1",
"target": {
"file": "kernel/bpf/btf.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@e7e9c5b2dda29067332df2a85b0141a92b41f218",
"deprecated": false,
"digest": {
"line_hashes": [
"166711389120971000291988022146719967725",
"111984770891178289136765454580998427811",
"62773279968114150258544609115059476840",
"103271792479843919180772945940173138934",
"281439174755027468164653095624559679255",
"134476483682048241830679072764746271434",
"105431822287930736507063801791667573778"
],
"threshold": 0.9
},
"id": "CVE-2024-49850-88151bcb",
"signature_type": "Line"
}
]