aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAlexei Starovoitov <ast@kernel.org>2018-01-19 21:37:01 -0500
committerAlexei Starovoitov <ast@kernel.org>2018-01-19 21:37:02 -0500
commit1391040b6570584c177a238eeac01930beabbaa4 (patch)
treef94d94db60f1bd595fc080694f8660566eeaf28b /tools
parent417f1d9f217922d822b64e8323458d7d03a12d4f (diff)
parent1728a4f2ad6840746a6b1b9f01d652c5842f7e8d (diff)
Merge branch 'bpf-misc-improvements'
Daniel Borkmann says: ==================== This series adds various misc improvements to BPF: detection of BPF helper definition misconfiguration for mem/size argument pairs, csum_diff helper also for XDP, various test cases, removal of the recently added pure_initcall(), restriction of the jit sysctls to cap_sys_admin for initns, a minor size improvement for x86 jit in alu ops, output of complexity limit to verifier log and last but not least having the event output more flexible with moving to const_size_or_zero type. Thanks! ==================== Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/selftests/bpf/test_verifier.c87
1 files changed, 87 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
index 6c22edb1f006..efca10de64e9 100644
--- a/tools/testing/selftests/bpf/test_verifier.c
+++ b/tools/testing/selftests/bpf/test_verifier.c
@@ -102,6 +102,93 @@ static struct bpf_test tests[] = {
102 .retval = -3, 102 .retval = -3,
103 }, 103 },
104 { 104 {
105 "DIV32 by 0, zero check 1",
106 .insns = {
107 BPF_MOV32_IMM(BPF_REG_0, 42),
108 BPF_MOV32_IMM(BPF_REG_1, 0),
109 BPF_MOV32_IMM(BPF_REG_2, 1),
110 BPF_ALU32_REG(BPF_DIV, BPF_REG_2, BPF_REG_1),
111 BPF_EXIT_INSN(),
112 },
113 .result = ACCEPT,
114 .retval = 0,
115 },
116 {
117 "DIV32 by 0, zero check 2",
118 .insns = {
119 BPF_MOV32_IMM(BPF_REG_0, 42),
120 BPF_LD_IMM64(BPF_REG_1, 0xffffffff00000000LL),
121 BPF_MOV32_IMM(BPF_REG_2, 1),
122 BPF_ALU32_REG(BPF_DIV, BPF_REG_2, BPF_REG_1),
123 BPF_EXIT_INSN(),
124 },
125 .result = ACCEPT,
126 .retval = 0,
127 },
128 {
129 "DIV64 by 0, zero check",
130 .insns = {
131 BPF_MOV32_IMM(BPF_REG_0, 42),
132 BPF_MOV32_IMM(BPF_REG_1, 0),
133 BPF_MOV32_IMM(BPF_REG_2, 1),
134 BPF_ALU64_REG(BPF_DIV, BPF_REG_2, BPF_REG_1),
135 BPF_EXIT_INSN(),
136 },
137 .result = ACCEPT,
138 .retval = 0,
139 },
140 {
141 "MOD32 by 0, zero check 1",
142 .insns = {
143 BPF_MOV32_IMM(BPF_REG_0, 42),
144 BPF_MOV32_IMM(BPF_REG_1, 0),
145 BPF_MOV32_IMM(BPF_REG_2, 1),
146 BPF_ALU32_REG(BPF_MOD, BPF_REG_2, BPF_REG_1),
147 BPF_EXIT_INSN(),
148 },
149 .result = ACCEPT,
150 .retval = 0,
151 },
152 {
153 "MOD32 by 0, zero check 2",
154 .insns = {
155 BPF_MOV32_IMM(BPF_REG_0, 42),
156 BPF_LD_IMM64(BPF_REG_1, 0xffffffff00000000LL),
157 BPF_MOV32_IMM(BPF_REG_2, 1),
158 BPF_ALU32_REG(BPF_MOD, BPF_REG_2, BPF_REG_1),
159 BPF_EXIT_INSN(),
160 },
161 .result = ACCEPT,
162 .retval = 0,
163 },
164 {
165 "MOD64 by 0, zero check",
166 .insns = {
167 BPF_MOV32_IMM(BPF_REG_0, 42),
168 BPF_MOV32_IMM(BPF_REG_1, 0),
169 BPF_MOV32_IMM(BPF_REG_2, 1),
170 BPF_ALU64_REG(BPF_MOD, BPF_REG_2, BPF_REG_1),
171 BPF_EXIT_INSN(),
172 },
173 .result = ACCEPT,
174 .retval = 0,
175 },
176 {
177 "empty prog",
178 .insns = {
179 },
180 .errstr = "last insn is not an exit or jmp",
181 .result = REJECT,
182 },
183 {
184 "only exit insn",
185 .insns = {
186 BPF_EXIT_INSN(),
187 },
188 .errstr = "R0 !read_ok",
189 .result = REJECT,
190 },
191 {
105 "unreachable", 192 "unreachable",
106 .insns = { 193 .insns = {
107 BPF_EXIT_INSN(), 194 BPF_EXIT_INSN(),