Alexei Starovoitov 98d7ca374b bpf: Track delta between "linked" registers.
Compilers can generate the code
  r1 = r2
  r1 += 0x1
  if r2 < 1000 goto ...
  use knowledge of r2 range in subsequent r1 operations

So remember constant delta between r2 and r1 and update r1 after 'if' condition.

Unfortunately LLVM still uses this pattern for loops with 'can_loop' construct:
for (i = 0; i < 1000 && can_loop; i++)

The "undo" pass was introduced in LLVM
https://reviews.llvm.org/D121937
to prevent this optimization, but it cannot cover all cases.
Instead of fighting middle end optimizer in BPF backend teach the verifier
about this pattern.

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/bpf/20240613013815.953-3-alexei.starovoitov@gmail.com
2024-06-14 21:52:39 +02:00
..
2024-05-19 11:38:15 -07:00
2024-05-13 14:14:05 -07:00
2024-05-22 10:49:54 -07:00
2024-05-22 12:13:40 -07:00
2024-05-27 08:09:12 -07:00
2024-05-22 11:53:02 -07:00
2024-05-21 15:29:01 -07:00
2024-05-17 17:31:24 -07:00
2024-05-15 17:06:08 -07:00
2024-05-23 12:04:36 -07:00
2023-12-23 15:52:13 +01:00
2023-10-19 11:02:48 +02:00
2024-04-25 21:07:04 -07:00
2024-05-06 14:22:02 -06:00
2024-03-01 12:23:37 +01:00
2023-12-01 09:51:44 -08:00
2024-03-13 12:53:53 -07:00
2024-05-17 17:31:24 -07:00
2024-05-23 12:04:36 -07:00
2023-10-30 17:56:53 -10:00
2023-10-04 10:41:57 -07:00
2024-05-17 17:31:24 -07:00
2023-12-29 12:22:29 -08:00
2024-05-23 19:40:26 -07:00
2024-05-17 17:31:24 -07:00
2024-04-25 20:56:00 -07:00