]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
selftests/bpf: Update reg_bound range refinement logic
authorPaul Chaignon <paul.chaignon@gmail.com>
Mon, 28 Jul 2025 09:51:16 +0000 (11:51 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Mon, 28 Jul 2025 17:02:12 +0000 (10:02 -0700)
This patch updates the range refinement logic in the reg_bound test to
match the new logic from the previous commit. Without this change, tests
would fail because we end with more precise ranges than the tests
expect.

Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
Link: https://lore.kernel.org/r/b7f6b1fbe03373cca4e1bb6a113035a6cd2b3ff7.1753695655.git.paul.chaignon@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/prog_tests/reg_bounds.c

index 39d42271cc4606955e4432920b86abd944ca4f33..e261b0e872dbbaecface5583fb68901e8c323077 100644 (file)
@@ -465,6 +465,20 @@ static struct range range_refine(enum num_t x_t, struct range x, enum num_t y_t,
                return range_improve(x_t, x, x_swap);
        }
 
+       if (!t_is_32(x_t) && !t_is_32(y_t) && x_t != y_t) {
+               if (x_t == S64 && x.a > x.b) {
+                       if (x.b < y.a && x.a <= y.b)
+                               return range(x_t, x.a, y.b);
+                       if (x.a > y.b && x.b >= y.a)
+                               return range(x_t, y.a, x.b);
+               } else if (x_t == U64 && y.a > y.b) {
+                       if (y.b < x.a && y.a <= x.b)
+                               return range(x_t, y.a, x.b);
+                       if (y.a > x.b && y.b >= x.a)
+                               return range(x_t, x.a, y.b);
+               }
+       }
+
        /* otherwise, plain range cast and intersection works */
        return range_improve(x_t, x, y_cast);
 }