The LLVM generated BPF byte codes need go through kernel
verifier before being allowed to execute in kernel.
performs path sensitive analysis to verify safety of the program.
The verification is done during bpf program loading time, and
typically right before the program starts to run.
Since verifier is executed in kernel space and it runs during program
loading time, there is a great effort to avoid introducing complexity
and running time overhead for it. Sometime, in order to add analysis
to verifier, user code hacking is conducted to workaround the issue.
Related to this patch, the following kernel patch is a workaround
for code generated by LLVM instcombine insertRangeTest().
https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit/?id=b7a0d65d80a0c5034b366392624397a0915b7556 107: w1 = w0 108: w1 += -1 109: if w1 > 6 goto -24 <LBB0_5> 110: w0 += w8
Basically since verifier does not record and propagate copy state
for performance and memory reasons. Register "w0" value range
will become conservative and later on may cause verification failure.
Another example is
People has to come up with weird ways to workaround this issue.
To improve user space usability, this patch proposed to disable
insertRangeTest() for bpf target. All other targets are not