bpf, arm64: Clear prog->jited_len along prog->jited
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ db496944fdaaf2a67d2f60529f5dc23abf809506 · < 41f7c4f85d402043687e863627a1a84fa867c62d| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
bpf, arm64: Clear prog->jited_len along prog->jited
syzbot reported an illegal copy_to_user() attempt from bpf_prog_get_info_by_fd() [1]
There was no repro yet on this bug, but I think that commit 0aef499f3172 ("mm/usercopy: Detect vmalloc overruns") is exposing a prior bug in bpf arm64.
bpf_prog_get_info_by_fd() looks at prog->jited_len to determine if the JIT image can be copied out to user space.
My theory is that syzbot managed to get a prog where prog->jited_len has been set to 43, while prog->bpf_func has ben cleared.
It is not clear why copy_to_user(uinsns, NULL, ulen) is triggering this particular warning.
I thought find_vma_area(NULL) would not find a vm_struct. As we do not hold vmap_area_lock spinlock, it might be possible that the found vm_struct was garbage.
From the CVE record · Linux
The Linux kernel’s arm64 BPF JIT can leave a program’s JIT length set after its JIT image is cleared. A local call to retrieve BPF program information triggered a user-copy warning and kernel BUG in testing; the report provides no reproducer and does not establish authentication requirements.
Engineers running Linux kernels with the arm64 BPF JIT should check their exposure; affected versions are not specified.