The LLVM generated BPF byte codes need go through kernel
verifier before being allowed to execute in kernel.
Kernel verifier
https://github.com/torvalds/linux/blob/master/kernel/bpf/verifier.c
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
https://lore.kernel.org/netdev/871019a0-71f8-c26d-0ae8-c7fd8c8867fc@fb.com/
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
affected.