bpf: Detect IP == ksym.end as part of BPF program
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ 74451e66d516c55e309e8d89a4a1e7596e46aacd · < 66d9111f3517f85ef2af0337ece02683ce0faf21| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
bpf: Detect IP == ksym.end as part of BPF program
Now that bpf_throw kfunc is the first such call instruction that has noreturn semantics within the verifier, this also kicks in dead code elimination in unprecedented ways. For one, any instruction following a bpf_throw call will never be marked as seen. Moreover, if a callchain ends up throwing, any instructions after the call instruction to the eventually throwing subprog in callers will also never be marked as seen.
The tempting way to fix this would be to emit extra 'int3' instructions which bump the jited_len of a program, and ensure that during runtime when a program throws, we can discover its boundaries even if the call instruction to bpf_throw (or to subprogs that always throw) is emitted as the final instruction in the program.
An example of such a program would be this:
do_something(): ... r0 = 0 exit
foo(): r1 = 0 call bpf_throw r0 = 0 exit
bar(cond): if r1 != 0 goto pc+2 call do_something exit call foo r0 = 0 // Never seen by verifier exit //
From the CVE record · Linux
The Linux kernel can fail to recognize a BPF program's return address when a JIT-compiled call that ultimately reaches bpf_throw is its final emitted instruction. This can cause a kernel panic during stack unwinding. The input does not specify whether exploitation requires local or network access, authentication, or user interaction.
Engineers running Linux kernels with BPF support should check their versions; affected versions are not specified in the input.