Re: [PATCH bpf-next v2 2/2] selftests/bpf: Check when bounds are not in the 32-bit range

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/26/2023 9:10 AM, Alexei Starovoitov wrote:
On Wed, Mar 22, 2023 at 2:38 PM Daniel Borkmann <daniel@xxxxxxxxxxxxx> wrote:

From: Xu Kuohai <xukuohai@xxxxxxxxxx>

Add cases to check if bound is updated correctly when 64-bit value is
not in the 32-bit range.

Signed-off-by: Xu Kuohai <xukuohai@xxxxxxxxxx>
Signed-off-by: Daniel Borkmann <daniel@xxxxxxxxxxxxx>
Acked-by: John Fastabend <john.fastabend@xxxxxxxxx>
---
  tools/testing/selftests/bpf/verifier/bounds.c | 121 ++++++++++++++++++
  1 file changed, 121 insertions(+)

diff --git a/tools/testing/selftests/bpf/verifier/bounds.c b/tools/testing/selftests/bpf/verifier/bounds.c
index 33125d5f6772..74b1917d4208 100644
--- a/tools/testing/selftests/bpf/verifier/bounds.c
+++ b/tools/testing/selftests/bpf/verifier/bounds.c
...
+       BPF_LDX_MEM(BPF_B, BPF_REG_1, BPF_REG_2, 0),
+       BPF_LD_IMM64(BPF_REG_0, 0x7fffffffffffff10),
+       BPF_ALU64_REG(BPF_ADD, BPF_REG_1, BPF_REG_0),
+
+       BPF_LD_IMM64(BPF_REG_0, 0x8000000000000000),
+       BPF_ALU64_IMM(BPF_ADD, BPF_REG_0, 1),
+       /* r1 signed range is [S64_MIN, S64_MAX] */
+       BPF_JMP_REG(BPF_JSLT, BPF_REG_0, BPF_REG_1, -2),
...
+       BPF_MOV32_IMM(BPF_REG_0, 0x80000000),
+       BPF_ALU32_IMM(BPF_ADD, BPF_REG_0, 1),
+       /* r1 signed range is [S32_MIN, S32_MAX] */
+       BPF_JMP32_REG(BPF_JSLT, BPF_REG_0, BPF_REG_1, -2),
+
+       BPF_MOV64_IMM(BPF_REG_0, 0),
+       BPF_EXIT_INSN(),
+       },
+       .errstr = "BPF program is too large",

These infinite loops take a very long time to execute.
The test_verifier got a lot slower because of these tests.
These infinite loops don't add much value to the actual test.
Please rewrite them without infinite loops.
.

Sorry for that. I've sent a patch to remove these two cases.



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux