1 /* Just make sure that JITs used udiv/umod as otherwise we get
2 * an exception from INT_MIN/-1 overflow similarly as with div
6 "DIV32 overflow, check 1",
8 BPF_MOV32_IMM(BPF_REG_1
, -1),
9 BPF_MOV32_IMM(BPF_REG_0
, INT_MIN
),
10 BPF_ALU32_REG(BPF_DIV
, BPF_REG_0
, BPF_REG_1
),
13 .prog_type
= BPF_PROG_TYPE_SCHED_CLS
,
18 "DIV32 overflow, check 2",
20 BPF_MOV32_IMM(BPF_REG_0
, INT_MIN
),
21 BPF_ALU32_IMM(BPF_DIV
, BPF_REG_0
, -1),
24 .prog_type
= BPF_PROG_TYPE_SCHED_CLS
,
29 "DIV64 overflow, check 1",
31 BPF_MOV64_IMM(BPF_REG_1
, -1),
32 BPF_LD_IMM64(BPF_REG_2
, LLONG_MIN
),
33 BPF_ALU64_REG(BPF_DIV
, BPF_REG_2
, BPF_REG_1
),
34 BPF_MOV32_IMM(BPF_REG_0
, 0),
35 BPF_JMP_REG(BPF_JEQ
, BPF_REG_0
, BPF_REG_2
, 1),
36 BPF_MOV32_IMM(BPF_REG_0
, 1),
39 .prog_type
= BPF_PROG_TYPE_SCHED_CLS
,
44 "DIV64 overflow, check 2",
46 BPF_LD_IMM64(BPF_REG_1
, LLONG_MIN
),
47 BPF_ALU64_IMM(BPF_DIV
, BPF_REG_1
, -1),
48 BPF_MOV32_IMM(BPF_REG_0
, 0),
49 BPF_JMP_REG(BPF_JEQ
, BPF_REG_0
, BPF_REG_1
, 1),
50 BPF_MOV32_IMM(BPF_REG_0
, 1),
53 .prog_type
= BPF_PROG_TYPE_SCHED_CLS
,
58 "MOD32 overflow, check 1",
60 BPF_MOV32_IMM(BPF_REG_1
, -1),
61 BPF_MOV32_IMM(BPF_REG_0
, INT_MIN
),
62 BPF_ALU32_REG(BPF_MOD
, BPF_REG_0
, BPF_REG_1
),
65 .prog_type
= BPF_PROG_TYPE_SCHED_CLS
,
70 "MOD32 overflow, check 2",
72 BPF_MOV32_IMM(BPF_REG_0
, INT_MIN
),
73 BPF_ALU32_IMM(BPF_MOD
, BPF_REG_0
, -1),
76 .prog_type
= BPF_PROG_TYPE_SCHED_CLS
,
81 "MOD64 overflow, check 1",
83 BPF_MOV64_IMM(BPF_REG_1
, -1),
84 BPF_LD_IMM64(BPF_REG_2
, LLONG_MIN
),
85 BPF_MOV64_REG(BPF_REG_3
, BPF_REG_2
),
86 BPF_ALU64_REG(BPF_MOD
, BPF_REG_2
, BPF_REG_1
),
87 BPF_MOV32_IMM(BPF_REG_0
, 0),
88 BPF_JMP_REG(BPF_JNE
, BPF_REG_3
, BPF_REG_2
, 1),
89 BPF_MOV32_IMM(BPF_REG_0
, 1),
92 .prog_type
= BPF_PROG_TYPE_SCHED_CLS
,
97 "MOD64 overflow, check 2",
99 BPF_LD_IMM64(BPF_REG_2
, LLONG_MIN
),
100 BPF_MOV64_REG(BPF_REG_3
, BPF_REG_2
),
101 BPF_ALU64_IMM(BPF_MOD
, BPF_REG_2
, -1),
102 BPF_MOV32_IMM(BPF_REG_0
, 0),
103 BPF_JMP_REG(BPF_JNE
, BPF_REG_3
, BPF_REG_2
, 1),
104 BPF_MOV32_IMM(BPF_REG_0
, 1),
107 .prog_type
= BPF_PROG_TYPE_SCHED_CLS
,