aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel/bpf/verifier.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 68568d22d6bd..f4ff0c569e54 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -263,6 +263,13 @@ static const char * const reg_type_str[] = {
263 [PTR_TO_PACKET_END] = "pkt_end", 263 [PTR_TO_PACKET_END] = "pkt_end",
264}; 264};
265 265
266static char slot_type_char[] = {
267 [STACK_INVALID] = '?',
268 [STACK_SPILL] = 'r',
269 [STACK_MISC] = 'm',
270 [STACK_ZERO] = '0',
271};
272
266static void print_liveness(struct bpf_verifier_env *env, 273static void print_liveness(struct bpf_verifier_env *env,
267 enum bpf_reg_liveness live) 274 enum bpf_reg_liveness live)
268{ 275{
@@ -349,15 +356,26 @@ static void print_verifier_state(struct bpf_verifier_env *env,
349 } 356 }
350 } 357 }
351 for (i = 0; i < state->allocated_stack / BPF_REG_SIZE; i++) { 358 for (i = 0; i < state->allocated_stack / BPF_REG_SIZE; i++) {
352 if (state->stack[i].slot_type[0] == STACK_SPILL) { 359 char types_buf[BPF_REG_SIZE + 1];
353 verbose(env, " fp%d", 360 bool valid = false;
354 (-i - 1) * BPF_REG_SIZE); 361 int j;
355 print_liveness(env, state->stack[i].spilled_ptr.live); 362
363 for (j = 0; j < BPF_REG_SIZE; j++) {
364 if (state->stack[i].slot_type[j] != STACK_INVALID)
365 valid = true;
366 types_buf[j] = slot_type_char[
367 state->stack[i].slot_type[j]];
368 }
369 types_buf[BPF_REG_SIZE] = 0;
370 if (!valid)
371 continue;
372 verbose(env, " fp%d", (-i - 1) * BPF_REG_SIZE);
373 print_liveness(env, state->stack[i].spilled_ptr.live);
374 if (state->stack[i].slot_type[0] == STACK_SPILL)
356 verbose(env, "=%s", 375 verbose(env, "=%s",
357 reg_type_str[state->stack[i].spilled_ptr.type]); 376 reg_type_str[state->stack[i].spilled_ptr.type]);
358 } 377 else
359 if (state->stack[i].slot_type[0] == STACK_ZERO) 378 verbose(env, "=%s", types_buf);
360 verbose(env, " fp%d=0", (-i - 1) * BPF_REG_SIZE);
361 } 379 }
362 verbose(env, "\n"); 380 verbose(env, "\n");
363} 381}