History

bpf: Small BPF verifier log improvements

In particular these include: 1) Remove output of inv for scalars in print_verifier_state 2) Replace inv with scalar in verifier error messages 3) Remove _value suffixes for umin/umax/s32_min/etc (except map_value) 4) Remove output of id=0 5) Remove output of ref_obj_id=0

Mykola Lysenko committed 4 years ago

Commit 7df50721 parent 41332d620 files · +203 −197Browse files

Unified · Split

20 files
  1. kernel/bpf/verifier.c +35 −29
  2. tools/testing/selftests/bpf/prog_tests/align.c +109 −109
  3. tools/testing/selftests/bpf/prog_tests/log_buf.c +2 −2
  4. tools/testing/selftests/bpf/verifier/atomic_invalid.c +3 −3
  5. tools/testing/selftests/bpf/verifier/bounds.c +2 −2
  6. tools/testing/selftests/bpf/verifier/calls.c +3 −3
  7. tools/testing/selftests/bpf/verifier/ctx.c +2 −2
  8. tools/testing/selftests/bpf/verifier/direct_packet_access.c +1 −1
  9. tools/testing/selftests/bpf/verifier/helper_access_var_len.c +3 −3
  10. tools/testing/selftests/bpf/verifier/jmp32.c +8 −8
  11. tools/testing/selftests/bpf/verifier/precise.c +2 −2
  12. tools/testing/selftests/bpf/verifier/raw_stack.c +2 −2
  13. tools/testing/selftests/bpf/verifier/ref_tracking.c +3 −3
  14. tools/testing/selftests/bpf/verifier/search_pruning.c +1 −1
  15. tools/testing/selftests/bpf/verifier/sock.c +1 −1
  16. tools/testing/selftests/bpf/verifier/spill_fill.c +19 −19
  17. tools/testing/selftests/bpf/verifier/unpriv.c +2 −2
  18. tools/testing/selftests/bpf/verifier/value_illegal_alu.c +2 −2
  19. tools/testing/selftests/bpf/verifier/value_ptr_arith.c +2 −2
  20. tools/testing/selftests/bpf/verifier/var_off.c +1 −1
kernel/bpf/verifier.c+35−29
@@ -539,7 +539,7 @@ static const char *reg_type_str(struct bpf_verifier_env *env, · 538 unmodified lines
539 char postfix[16] = {0}, prefix[32] = {0};539 char postfix[16] = {0}, prefix[32] = {0};
540 static const char * const str[] = {540 static const char * const str[] = {
541 [NOT_INIT] = "?",541 [NOT_INIT] = "?",
542 [SCALAR_VALUE] = "inv",542 [SCALAR_VALUE] = "scalar",
543 [PTR_TO_CTX] = "ctx",543 [PTR_TO_CTX] = "ctx",
544 [CONST_PTR_TO_MAP] = "map_ptr",544 [CONST_PTR_TO_MAP] = "map_ptr",
545 [PTR_TO_MAP_VALUE] = "map_value",545 [PTR_TO_MAP_VALUE] = "map_value",
@@ -685,74 +685,80 @@ static void print_verifier_state(struct bpf_verifier_env *env, · 139 unmodified lines
685 continue;685 continue;
686 verbose(env, " R%d", i);686 verbose(env, " R%d", i);
687 print_liveness(env, reg->live);687 print_liveness(env, reg->live);
688 verbose(env, "=%s", reg_type_str(env, t));688 verbose(env, "=");
689 if (t == SCALAR_VALUE && reg->precise)689 if (t == SCALAR_VALUE && reg->precise)
690 verbose(env, "P");690 verbose(env, "P");
691 if ((t == SCALAR_VALUE || t == PTR_TO_STACK) &&691 if ((t == SCALAR_VALUE || t == PTR_TO_STACK) &&
692 tnum_is_const(reg->var_off)) {692 tnum_is_const(reg->var_off)) {
693 /* reg->off should be 0 for SCALAR_VALUE */693 /* reg->off should be 0 for SCALAR_VALUE */
694 verbose(env, "%s", t == SCALAR_VALUE ? "" : reg_type_str(env, t));
694 verbose(env, "%lld", reg->var_off.value + reg->off);695 verbose(env, "%lld", reg->var_off.value + reg->off);
695 } else {696 } else {
697 const char *sep = "";
698
699 verbose(env, "%s", reg_type_str(env, t));
696 if (base_type(t) == PTR_TO_BTF_ID ||700 if (base_type(t) == PTR_TO_BTF_ID ||
697 base_type(t) == PTR_TO_PERCPU_BTF_ID)701 base_type(t) == PTR_TO_PERCPU_BTF_ID)
698 verbose(env, "%s", kernel_type_name(reg->btf, reg->btf_id));702 verbose(env, "%s", kernel_type_name(reg->btf, reg->btf_id));
699 verbose(env, "(id=%d", reg->id);703 verbose(env, "(");
700 if (reg_type_may_be_refcounted_or_null(t))704/*
701 verbose(env, ",ref_obj_id=%d", reg->ref_obj_id);705 * _a stands for append, was shortened to avoid multiline statements below.
706 * This macro is used to output a comma separated list of attributes.
707 */
708#define verbose_a(fmt, ...) ({ verbose(env, "%s" fmt, sep, __VA_ARGS__); sep = ","; })
709
710 if (reg->id)
711 verbose_a("id=%d", reg->id);
712 if (reg_type_may_be_refcounted_or_null(t) && reg->ref_obj_id)
713 verbose_a("ref_obj_id=%d", reg->ref_obj_id);
702 if (t != SCALAR_VALUE)714 if (t != SCALAR_VALUE)
703 verbose(env, ",off=%d", reg->off);715 verbose_a("off=%d", reg->off);
704 if (type_is_pkt_pointer(t))716 if (type_is_pkt_pointer(t))
705 verbose(env, ",r=%d", reg->range);717 verbose_a("r=%d", reg->range);
706 else if (base_type(t) == CONST_PTR_TO_MAP ||718 else if (base_type(t) == CONST_PTR_TO_MAP ||
707 base_type(t) == PTR_TO_MAP_KEY ||719 base_type(t) == PTR_TO_MAP_KEY ||
708 base_type(t) == PTR_TO_MAP_VALUE)720 base_type(t) == PTR_TO_MAP_VALUE)
709 verbose(env, ",ks=%d,vs=%d",721 verbose_a("ks=%d,vs=%d",
710 reg->map_ptr->key_size,722 reg->map_ptr->key_size,
711 reg->map_ptr->value_size);723 reg->map_ptr->value_size);
712 if (tnum_is_const(reg->var_off)) {724 if (tnum_is_const(reg->var_off)) {
713 /* Typically an immediate SCALAR_VALUE, but725 /* Typically an immediate SCALAR_VALUE, but
714 * could be a pointer whose offset is too big726 * could be a pointer whose offset is too big
715 * for reg->off727 * for reg->off
716 */728 */
717 verbose(env, ",imm=%llx", reg->var_off.value);729 verbose_a("imm=%llx", reg->var_off.value);
718 } else {730 } else {
719 if (reg->smin_value != reg->umin_value &&731 if (reg->smin_value != reg->umin_value &&
720 reg->smin_value != S64_MIN)732 reg->smin_value != S64_MIN)
721 verbose(env, ",smin_value=%lld",733 verbose_a("smin=%lld", (long long)reg->smin_value);
722 (long long)reg->smin_value);
723 if (reg->smax_value != reg->umax_value &&734 if (reg->smax_value != reg->umax_value &&
724 reg->smax_value != S64_MAX)735 reg->smax_value != S64_MAX)
725 verbose(env, ",smax_value=%lld",736 verbose_a("smax=%lld", (long long)reg->smax_value);
726 (long long)reg->smax_value);
727 if (reg->umin_value != 0)737 if (reg->umin_value != 0)
728 verbose(env, ",umin_value=%llu",738 verbose_a("umin=%llu", (unsigned long long)reg->umin_value);
729 (unsigned long long)reg->umin_value);
730 if (reg->umax_value != U64_MAX)739 if (reg->umax_value != U64_MAX)
731 verbose(env, ",umax_value=%llu",740 verbose_a("umax=%llu", (unsigned long long)reg->umax_value);
732 (unsigned long long)reg->umax_value);
733 if (!tnum_is_unknown(reg->var_off)) {741 if (!tnum_is_unknown(reg->var_off)) {
734 char tn_buf[48];742 char tn_buf[48];
735 743
736 tnum_strn(tn_buf, sizeof(tn_buf), reg->var_off);744 tnum_strn(tn_buf, sizeof(tn_buf), reg->var_off);
737 verbose(env, ",var_off=%s", tn_buf);745 verbose_a("var_off=%s", tn_buf);
738 }746 }
739 if (reg->s32_min_value != reg->smin_value &&747 if (reg->s32_min_value != reg->smin_value &&
740 reg->s32_min_value != S32_MIN)748 reg->s32_min_value != S32_MIN)
741 verbose(env, ",s32_min_value=%d",749 verbose_a("s32_min=%d", (int)(reg->s32_min_value));
742 (int)(reg->s32_min_value));
743 if (reg->s32_max_value != reg->smax_value &&750 if (reg->s32_max_value != reg->smax_value &&
744 reg->s32_max_value != S32_MAX)751 reg->s32_max_value != S32_MAX)
745 verbose(env, ",s32_max_value=%d",752 verbose_a("s32_max=%d", (int)(reg->s32_max_value));
746 (int)(reg->s32_max_value));
747 if (reg->u32_min_value != reg->umin_value &&753 if (reg->u32_min_value != reg->umin_value &&
748 reg->u32_min_value != U32_MIN)754 reg->u32_min_value != U32_MIN)
749 verbose(env, ",u32_min_value=%d",755 verbose_a("u32_min=%d", (int)(reg->u32_min_value));
750 (int)(reg->u32_min_value));
751 if (reg->u32_max_value != reg->umax_value &&756 if (reg->u32_max_value != reg->umax_value &&
752 reg->u32_max_value != U32_MAX)757 reg->u32_max_value != U32_MAX)
753 verbose(env, ",u32_max_value=%d",758 verbose_a("u32_max=%d", (int)(reg->u32_max_value));
754 (int)(reg->u32_max_value));
755 }759 }
760#undef verbose_a
761
756 verbose(env, ")");762 verbose(env, ")");
757 }763 }
758 }764 }
@@ -777,7 +783,7 @@ static void print_verifier_state(struct bpf_verifier_env *env, · 18 unmodified lines
777 if (is_spilled_reg(&state->stack[i])) {783 if (is_spilled_reg(&state->stack[i])) {
778 reg = &state->stack[i].spilled_ptr;784 reg = &state->stack[i].spilled_ptr;
779 t = reg->type;785 t = reg->type;
780 verbose(env, "=%s", reg_type_str(env, t));786 verbose(env, "=%s", t == SCALAR_VALUE ? "" : reg_type_str(env, t));
781 if (t == SCALAR_VALUE && reg->precise)787 if (t == SCALAR_VALUE && reg->precise)
782 verbose(env, "P");788 verbose(env, "P");
783 if (t == SCALAR_VALUE && tnum_is_const(reg->var_off))789 if (t == SCALAR_VALUE && tnum_is_const(reg->var_off))
tools/testing/selftests/bpf/prog_tests/align.c+109−109
@@ -39,13 +39,13 @@ static struct bpf_align_test tests[] = { · 38 unmodified lines
39 },39 },
40 .prog_type = BPF_PROG_TYPE_SCHED_CLS,40 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
41 .matches = {41 .matches = {
42 {0, "R1=ctx(id=0,off=0,imm=0)"},42 {0, "R1=ctx(off=0,imm=0)"},
43 {0, "R10=fp0"},43 {0, "R10=fp0"},
44 {0, "R3_w=inv2"},44 {0, "R3_w=2"},
45 {1, "R3_w=inv4"},45 {1, "R3_w=4"},
46 {2, "R3_w=inv8"},46 {2, "R3_w=8"},
47 {3, "R3_w=inv16"},47 {3, "R3_w=16"},
48 {4, "R3_w=inv32"},48 {4, "R3_w=32"},
49 },49 },
50 },50 },
51 {51 {
@@ -67,19 +67,19 @@ static struct bpf_align_test tests[] = { · 15 unmodified lines
67 },67 },
68 .prog_type = BPF_PROG_TYPE_SCHED_CLS,68 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
69 .matches = {69 .matches = {
70 {0, "R1=ctx(id=0,off=0,imm=0)"},70 {0, "R1=ctx(off=0,imm=0)"},
71 {0, "R10=fp0"},71 {0, "R10=fp0"},
72 {0, "R3_w=inv1"},72 {0, "R3_w=1"},
73 {1, "R3_w=inv2"},73 {1, "R3_w=2"},
74 {2, "R3_w=inv4"},74 {2, "R3_w=4"},
75 {3, "R3_w=inv8"},75 {3, "R3_w=8"},
76 {4, "R3_w=inv16"},76 {4, "R3_w=16"},
77 {5, "R3_w=inv1"},77 {5, "R3_w=1"},
78 {6, "R4_w=inv32"},78 {6, "R4_w=32"},
79 {7, "R4_w=inv16"},79 {7, "R4_w=16"},
80 {8, "R4_w=inv8"},80 {8, "R4_w=8"},
81 {9, "R4_w=inv4"},81 {9, "R4_w=4"},
82 {10, "R4_w=inv2"},82 {10, "R4_w=2"},
83 },83 },
84 },84 },
85 {85 {
@@ -96,14 +96,14 @@ static struct bpf_align_test tests[] = { · 10 unmodified lines
96 },96 },
97 .prog_type = BPF_PROG_TYPE_SCHED_CLS,97 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
98 .matches = {98 .matches = {
99 {0, "R1=ctx(id=0,off=0,imm=0)"},99 {0, "R1=ctx(off=0,imm=0)"},
100 {0, "R10=fp0"},100 {0, "R10=fp0"},
101 {0, "R3_w=inv4"},101 {0, "R3_w=4"},
102 {1, "R3_w=inv8"},102 {1, "R3_w=8"},
103 {2, "R3_w=inv10"},103 {2, "R3_w=10"},
104 {3, "R4_w=inv8"},104 {3, "R4_w=8"},
105 {4, "R4_w=inv12"},105 {4, "R4_w=12"},
106 {5, "R4_w=inv14"},106 {5, "R4_w=14"},
107 },107 },
108 },108 },
109 {109 {
@@ -118,12 +118,12 @@ static struct bpf_align_test tests[] = { · 8 unmodified lines
118 },118 },
119 .prog_type = BPF_PROG_TYPE_SCHED_CLS,119 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
120 .matches = {120 .matches = {
121 {0, "R1=ctx(id=0,off=0,imm=0)"},121 {0, "R1=ctx(off=0,imm=0)"},
122 {0, "R10=fp0"},122 {0, "R10=fp0"},
123 {0, "R3_w=inv7"},123 {0, "R3_w=7"},
124 {1, "R3_w=inv7"},124 {1, "R3_w=7"},
125 {2, "R3_w=inv14"},125 {2, "R3_w=14"},
126 {3, "R3_w=inv56"},126 {3, "R3_w=56"},
127 },127 },
128 },128 },
129 129
@@ -161,19 +161,19 @@ static struct bpf_align_test tests[] = { · 31 unmodified lines
161 },161 },
162 .prog_type = BPF_PROG_TYPE_SCHED_CLS,162 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
163 .matches = {163 .matches = {
164 {6, "R0_w=pkt(id=0,off=8,r=8,imm=0)"},164 {6, "R0_w=pkt(off=8,r=8,imm=0)"},
165 {6, "R3_w=inv(id=0,umax_value=255,var_off=(0x0; 0xff))"},165 {6, "R3_w=scalar(umax=255,var_off=(0x0; 0xff))"},
166 {7, "R3_w=inv(id=0,umax_value=510,var_off=(0x0; 0x1fe))"},166 {7, "R3_w=scalar(umax=510,var_off=(0x0; 0x1fe))"},
167 {8, "R3_w=inv(id=0,umax_value=1020,var_off=(0x0; 0x3fc))"},167 {8, "R3_w=scalar(umax=1020,var_off=(0x0; 0x3fc))"},
168 {9, "R3_w=inv(id=0,umax_value=2040,var_off=(0x0; 0x7f8))"},168 {9, "R3_w=scalar(umax=2040,var_off=(0x0; 0x7f8))"},
169 {10, "R3_w=inv(id=0,umax_value=4080,var_off=(0x0; 0xff0))"},169 {10, "R3_w=scalar(umax=4080,var_off=(0x0; 0xff0))"},
170 {12, "R3_w=pkt_end(id=0,off=0,imm=0)"},170 {12, "R3_w=pkt_end(off=0,imm=0)"},
171 {17, "R4_w=inv(id=0,umax_value=255,var_off=(0x0; 0xff))"},171 {17, "R4_w=scalar(umax=255,var_off=(0x0; 0xff))"},
172 {18, "R4_w=inv(id=0,umax_value=8160,var_off=(0x0; 0x1fe0))"},172 {18, "R4_w=scalar(umax=8160,var_off=(0x0; 0x1fe0))"},
173 {19, "R4_w=inv(id=0,umax_value=4080,var_off=(0x0; 0xff0))"},173 {19, "R4_w=scalar(umax=4080,var_off=(0x0; 0xff0))"},
174 {20, "R4_w=inv(id=0,umax_value=2040,var_off=(0x0; 0x7f8))"},174 {20, "R4_w=scalar(umax=2040,var_off=(0x0; 0x7f8))"},
175 {21, "R4_w=inv(id=0,umax_value=1020,var_off=(0x0; 0x3fc))"},175 {21, "R4_w=scalar(umax=1020,var_off=(0x0; 0x3fc))"},
176 {22, "R4_w=inv(id=0,umax_value=510,var_off=(0x0; 0x1fe))"},176 {22, "R4_w=scalar(umax=510,var_off=(0x0; 0x1fe))"},
177 },177 },
178 },178 },
179 {179 {
@@ -194,16 +194,16 @@ static struct bpf_align_test tests[] = { · 14 unmodified lines
194 },194 },
195 .prog_type = BPF_PROG_TYPE_SCHED_CLS,195 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
196 .matches = {196 .matches = {
197 {6, "R3_w=inv(id=0,umax_value=255,var_off=(0x0; 0xff))"},197 {6, "R3_w=scalar(umax=255,var_off=(0x0; 0xff))"},
198 {7, "R4_w=inv(id=1,umax_value=255,var_off=(0x0; 0xff))"},198 {7, "R4_w=scalar(id=1,umax=255,var_off=(0x0; 0xff))"},
199 {8, "R4_w=inv(id=0,umax_value=255,var_off=(0x0; 0xff))"},199 {8, "R4_w=scalar(umax=255,var_off=(0x0; 0xff))"},
200 {9, "R4_w=inv(id=1,umax_value=255,var_off=(0x0; 0xff))"},200 {9, "R4_w=scalar(id=1,umax=255,var_off=(0x0; 0xff))"},
201 {10, "R4_w=inv(id=0,umax_value=510,var_off=(0x0; 0x1fe))"},201 {10, "R4_w=scalar(umax=510,var_off=(0x0; 0x1fe))"},
202 {11, "R4_w=inv(id=1,umax_value=255,var_off=(0x0; 0xff))"},202 {11, "R4_w=scalar(id=1,umax=255,var_off=(0x0; 0xff))"},
203 {12, "R4_w=inv(id=0,umax_value=1020,var_off=(0x0; 0x3fc))"},203 {12, "R4_w=scalar(umax=1020,var_off=(0x0; 0x3fc))"},
204 {13, "R4_w=inv(id=1,umax_value=255,var_off=(0x0; 0xff))"},204 {13, "R4_w=scalar(id=1,umax=255,var_off=(0x0; 0xff))"},
205 {14, "R4_w=inv(id=0,umax_value=2040,var_off=(0x0; 0x7f8))"},205 {14, "R4_w=scalar(umax=2040,var_off=(0x0; 0x7f8))"},
206 {15, "R4_w=inv(id=0,umax_value=4080,var_off=(0x0; 0xff0))"},206 {15, "R4_w=scalar(umax=4080,var_off=(0x0; 0xff0))"},
207 },207 },
208 },208 },
209 {209 {
@@ -234,14 +234,14 @@ static struct bpf_align_test tests[] = { · 24 unmodified lines
234 },234 },
235 .prog_type = BPF_PROG_TYPE_SCHED_CLS,235 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
236 .matches = {236 .matches = {
237 {2, "R5_w=pkt(id=0,off=0,r=0,imm=0)"},237 {2, "R5_w=pkt(off=0,r=0,imm=0)"},
238 {4, "R5_w=pkt(id=0,off=14,r=0,imm=0)"},238 {4, "R5_w=pkt(off=14,r=0,imm=0)"},
239 {5, "R4_w=pkt(id=0,off=14,r=0,imm=0)"},239 {5, "R4_w=pkt(off=14,r=0,imm=0)"},
240 {9, "R2=pkt(id=0,off=0,r=18,imm=0)"},240 {9, "R2=pkt(off=0,r=18,imm=0)"},
241 {10, "R5=pkt(id=0,off=14,r=18,imm=0)"},241 {10, "R5=pkt(off=14,r=18,imm=0)"},
242 {10, "R4_w=inv(id=0,umax_value=255,var_off=(0x0; 0xff))"},242 {10, "R4_w=scalar(umax=255,var_off=(0x0; 0xff))"},
243 {13, "R4_w=inv(id=0,umax_value=65535,var_off=(0x0; 0xffff))"},243 {13, "R4_w=scalar(umax=65535,var_off=(0x0; 0xffff))"},
244 {14, "R4_w=inv(id=0,umax_value=65535,var_off=(0x0; 0xffff))"},244 {14, "R4_w=scalar(umax=65535,var_off=(0x0; 0xffff))"},
245 },245 },
246 },246 },
247 {247 {
@@ -296,59 +296,59 @@ static struct bpf_align_test tests[] = { · 48 unmodified lines
296 /* Calculated offset in R6 has unknown value, but known296 /* Calculated offset in R6 has unknown value, but known
297 * alignment of 4.297 * alignment of 4.
298 */298 */
299 {6, "R2_w=pkt(id=0,off=0,r=8,imm=0)"},299 {6, "R2_w=pkt(off=0,r=8,imm=0)"},
300 {7, "R6_w=inv(id=0,umax_value=1020,var_off=(0x0; 0x3fc))"},300 {7, "R6_w=scalar(umax=1020,var_off=(0x0; 0x3fc))"},
301 /* Offset is added to packet pointer R5, resulting in301 /* Offset is added to packet pointer R5, resulting in
302 * known fixed offset, and variable offset from R6.302 * known fixed offset, and variable offset from R6.
303 */303 */
304 {11, "R5_w=pkt(id=1,off=14,r=0,umax_value=1020,var_off=(0x0; 0x3fc))"},304 {11, "R5_w=pkt(id=1,off=14,r=0,umax=1020,var_off=(0x0; 0x3fc))"},
305 /* At the time the word size load is performed from R5,305 /* At the time the word size load is performed from R5,
306 * it's total offset is NET_IP_ALIGN + reg->off (0) +306 * it's total offset is NET_IP_ALIGN + reg->off (0) +
307 * reg->aux_off (14) which is 16. Then the variable307 * reg->aux_off (14) which is 16. Then the variable
308 * offset is considered using reg->aux_off_align which308 * offset is considered using reg->aux_off_align which
309 * is 4 and meets the load's requirements.309 * is 4 and meets the load's requirements.
310 */310 */
311 {15, "R4=pkt(id=1,off=18,r=18,umax_value=1020,var_off=(0x0; 0x3fc))"},311 {15, "R4=pkt(id=1,off=18,r=18,umax=1020,var_off=(0x0; 0x3fc))"},
312 {15, "R5=pkt(id=1,off=14,r=18,umax_value=1020,var_off=(0x0; 0x3fc))"},312 {15, "R5=pkt(id=1,off=14,r=18,umax=1020,var_off=(0x0; 0x3fc))"},
313 /* Variable offset is added to R5 packet pointer,313 /* Variable offset is added to R5 packet pointer,
314 * resulting in auxiliary alignment of 4.314 * resulting in auxiliary alignment of 4.
315 */315 */
316 {17, "R5_w=pkt(id=2,off=0,r=0,umax_value=1020,var_off=(0x0; 0x3fc))"},316 {17, "R5_w=pkt(id=2,off=0,r=0,umax=1020,var_off=(0x0; 0x3fc))"},
317 /* Constant offset is added to R5, resulting in317 /* Constant offset is added to R5, resulting in
318 * reg->off of 14.318 * reg->off of 14.
319 */319 */
320 {18, "R5_w=pkt(id=2,off=14,r=0,umax_value=1020,var_off=(0x0; 0x3fc))"},320 {18, "R5_w=pkt(id=2,off=14,r=0,umax=1020,var_off=(0x0; 0x3fc))"},
321 /* At the time the word size load is performed from R5,321 /* At the time the word size load is performed from R5,
322 * its total fixed offset is NET_IP_ALIGN + reg->off322 * its total fixed offset is NET_IP_ALIGN + reg->off
323 * (14) which is 16. Then the variable offset is 4-byte323 * (14) which is 16. Then the variable offset is 4-byte
324 * aligned, so the total offset is 4-byte aligned and324 * aligned, so the total offset is 4-byte aligned and
325 * meets the load's requirements.325 * meets the load's requirements.
326 */326 */
327 {23, "R4=pkt(id=2,off=18,r=18,umax_value=1020,var_off=(0x0; 0x3fc))"},327 {23, "R4=pkt(id=2,off=18,r=18,umax=1020,var_off=(0x0; 0x3fc))"},
328 {23, "R5=pkt(id=2,off=14,r=18,umax_value=1020,var_off=(0x0; 0x3fc))"},328 {23, "R5=pkt(id=2,off=14,r=18,umax=1020,var_off=(0x0; 0x3fc))"},
329 /* Constant offset is added to R5 packet pointer,329 /* Constant offset is added to R5 packet pointer,
330 * resulting in reg->off value of 14.330 * resulting in reg->off value of 14.
331 */331 */
332 {25, "R5_w=pkt(id=0,off=14,r=8"},332 {25, "R5_w=pkt(off=14,r=8"},
333 /* Variable offset is added to R5, resulting in a333 /* Variable offset is added to R5, resulting in a
334 * variable offset of (4n).334 * variable offset of (4n).
335 */335 */
336 {26, "R5_w=pkt(id=3,off=14,r=0,umax_value=1020,var_off=(0x0; 0x3fc))"},336 {26, "R5_w=pkt(id=3,off=14,r=0,umax=1020,var_off=(0x0; 0x3fc))"},
337 /* Constant is added to R5 again, setting reg->off to 18. */337 /* Constant is added to R5 again, setting reg->off to 18. */
338 {27, "R5_w=pkt(id=3,off=18,r=0,umax_value=1020,var_off=(0x0; 0x3fc))"},338 {27, "R5_w=pkt(id=3,off=18,r=0,umax=1020,var_off=(0x0; 0x3fc))"},
339 /* And once more we add a variable; resulting var_off339 /* And once more we add a variable; resulting var_off
340 * is still (4n), fixed offset is not changed.340 * is still (4n), fixed offset is not changed.
341 * Also, we create a new reg->id.341 * Also, we create a new reg->id.
342 */342 */
343 {28, "R5_w=pkt(id=4,off=18,r=0,umax_value=2040,var_off=(0x0; 0x7fc)"},343 {28, "R5_w=pkt(id=4,off=18,r=0,umax=2040,var_off=(0x0; 0x7fc)"},
344 /* At the time the word size load is performed from R5,344 /* At the time the word size load is performed from R5,
345 * its total fixed offset is NET_IP_ALIGN + reg->off (18)345 * its total fixed offset is NET_IP_ALIGN + reg->off (18)
346 * which is 20. Then the variable offset is (4n), so346 * which is 20. Then the variable offset is (4n), so
347 * the total offset is 4-byte aligned and meets the347 * the total offset is 4-byte aligned and meets the
348 * load's requirements.348 * load's requirements.
349 */349 */
350 {33, "R4=pkt(id=4,off=22,r=22,umax_value=2040,var_off=(0x0; 0x7fc)"},350 {33, "R4=pkt(id=4,off=22,r=22,umax=2040,var_off=(0x0; 0x7fc)"},
351 {33, "R5=pkt(id=4,off=18,r=22,umax_value=2040,var_off=(0x0; 0x7fc)"},351 {33, "R5=pkt(id=4,off=18,r=22,umax=2040,var_off=(0x0; 0x7fc)"},
352 },352 },
353 },353 },
354 {354 {
@@ -386,36 +386,36 @@ static struct bpf_align_test tests[] = { · 31 unmodified lines
386 /* Calculated offset in R6 has unknown value, but known386 /* Calculated offset in R6 has unknown value, but known
387 * alignment of 4.387 * alignment of 4.
388 */388 */
389 {6, "R2_w=pkt(id=0,off=0,r=8,imm=0)"},389 {6, "R2_w=pkt(off=0,r=8,imm=0)"},
390 {7, "R6_w=inv(id=0,umax_value=1020,var_off=(0x0; 0x3fc))"},390 {7, "R6_w=scalar(umax=1020,var_off=(0x0; 0x3fc))"},
391 /* Adding 14 makes R6 be (4n+2) */391 /* Adding 14 makes R6 be (4n+2) */
392 {8, "R6_w=inv(id=0,umin_value=14,umax_value=1034,var_off=(0x2; 0x7fc))"},392 {8, "R6_w=scalar(umin=14,umax=1034,var_off=(0x2; 0x7fc))"},
393 /* Packet pointer has (4n+2) offset */393 /* Packet pointer has (4n+2) offset */
394 {11, "R5_w=pkt(id=1,off=0,r=0,umin_value=14,umax_value=1034,var_off=(0x2; 0x7fc)"},394 {11, "R5_w=pkt(id=1,off=0,r=0,umin=14,umax=1034,var_off=(0x2; 0x7fc)"},
395 {12, "R4=pkt(id=1,off=4,r=0,umin_value=14,umax_value=1034,var_off=(0x2; 0x7fc)"},395 {12, "R4=pkt(id=1,off=4,r=0,umin=14,umax=1034,var_off=(0x2; 0x7fc)"},
396 /* At the time the word size load is performed from R5,396 /* At the time the word size load is performed from R5,
397 * its total fixed offset is NET_IP_ALIGN + reg->off (0)397 * its total fixed offset is NET_IP_ALIGN + reg->off (0)
398 * which is 2. Then the variable offset is (4n+2), so398 * which is 2. Then the variable offset is (4n+2), so
399 * the total offset is 4-byte aligned and meets the399 * the total offset is 4-byte aligned and meets the
400 * load's requirements.400 * load's requirements.
401 */401 */
402 {15, "R5=pkt(id=1,off=0,r=4,umin_value=14,umax_value=1034,var_off=(0x2; 0x7fc)"},402 {15, "R5=pkt(id=1,off=0,r=4,umin=14,umax=1034,var_off=(0x2; 0x7fc)"},
403 /* Newly read value in R6 was shifted left by 2, so has403 /* Newly read value in R6 was shifted left by 2, so has
404 * known alignment of 4.404 * known alignment of 4.
405 */405 */
406 {17, "R6_w=inv(id=0,umax_value=1020,var_off=(0x0; 0x3fc))"},406 {17, "R6_w=scalar(umax=1020,var_off=(0x0; 0x3fc))"},
407 /* Added (4n) to packet pointer's (4n+2) var_off, giving407 /* Added (4n) to packet pointer's (4n+2) var_off, giving
408 * another (4n+2).408 * another (4n+2).
409 */409 */
410 {19, "R5_w=pkt(id=2,off=0,r=0,umin_value=14,umax_value=2054,var_off=(0x2; 0xffc)"},410 {19, "R5_w=pkt(id=2,off=0,r=0,umin=14,umax=2054,var_off=(0x2; 0xffc)"},
411 {20, "R4=pkt(id=2,off=4,r=0,umin_value=14,umax_value=2054,var_off=(0x2; 0xffc)"},411 {20, "R4=pkt(id=2,off=4,r=0,umin=14,umax=2054,var_off=(0x2; 0xffc)"},
412 /* At the time the word size load is performed from R5,412 /* At the time the word size load is performed from R5,
413 * its total fixed offset is NET_IP_ALIGN + reg->off (0)413 * its total fixed offset is NET_IP_ALIGN + reg->off (0)
414 * which is 2. Then the variable offset is (4n+2), so414 * which is 2. Then the variable offset is (4n+2), so
415 * the total offset is 4-byte aligned and meets the415 * the total offset is 4-byte aligned and meets the
416 * load's requirements.416 * load's requirements.
417 */417 */
418 {23, "R5=pkt(id=2,off=0,r=4,umin_value=14,umax_value=2054,var_off=(0x2; 0xffc)"},418 {23, "R5=pkt(id=2,off=0,r=4,umin=14,umax=2054,var_off=(0x2; 0xffc)"},
419 },419 },
420 },420 },
421 {421 {
@@ -448,18 +448,18 @@ static struct bpf_align_test tests[] = { · 26 unmodified lines
448 .prog_type = BPF_PROG_TYPE_SCHED_CLS,448 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
449 .result = REJECT,449 .result = REJECT,
450 .matches = {450 .matches = {
451 {3, "R5_w=pkt_end(id=0,off=0,imm=0)"},451 {3, "R5_w=pkt_end(off=0,imm=0)"},
452 /* (ptr - ptr) << 2 == unknown, (4n) */452 /* (ptr - ptr) << 2 == unknown, (4n) */
453 {5, "R5_w=inv(id=0,smax_value=9223372036854775804,umax_value=18446744073709551612,var_off=(0x0; 0xfffffffffffffffc)"},453 {5, "R5_w=scalar(smax=9223372036854775804,umax=18446744073709551612,var_off=(0x0; 0xfffffffffffffffc)"},
454 /* (4n) + 14 == (4n+2). We blow our bounds, because454 /* (4n) + 14 == (4n+2). We blow our bounds, because
455 * the add could overflow.455 * the add could overflow.
456 */456 */
457 {6, "R5_w=inv(id=0,smin_value=-9223372036854775806,smax_value=9223372036854775806,umin_value=2,umax_value=18446744073709551614,var_off=(0x2; 0xfffffffffffffffc)"},457 {6, "R5_w=scalar(smin=-9223372036854775806,smax=9223372036854775806,umin=2,umax=18446744073709551614,var_off=(0x2; 0xfffffffffffffffc)"},
458 /* Checked s>=0 */458 /* Checked s>=0 */
459 {9, "R5=inv(id=0,umin_value=2,umax_value=9223372036854775806,var_off=(0x2; 0x7ffffffffffffffc)"},459 {9, "R5=scalar(umin=2,umax=9223372036854775806,var_off=(0x2; 0x7ffffffffffffffc)"},
460 /* packet pointer + nonnegative (4n+2) */460 /* packet pointer + nonnegative (4n+2) */
461 {11, "R6_w=pkt(id=1,off=0,r=0,umin_value=2,umax_value=9223372036854775806,var_off=(0x2; 0x7ffffffffffffffc)"},461 {11, "R6_w=pkt(id=1,off=0,r=0,umin=2,umax=9223372036854775806,var_off=(0x2; 0x7ffffffffffffffc)"},
462 {12, "R4_w=pkt(id=1,off=4,r=0,umin_value=2,umax_value=9223372036854775806,var_off=(0x2; 0x7ffffffffffffffc)"},462 {12, "R4_w=pkt(id=1,off=4,r=0,umin=2,umax=9223372036854775806,var_off=(0x2; 0x7ffffffffffffffc)"},
463 /* NET_IP_ALIGN + (4n+2) == (4n), alignment is fine.463 /* NET_IP_ALIGN + (4n+2) == (4n), alignment is fine.
464 * We checked the bounds, but it might have been able464 * We checked the bounds, but it might have been able
465 * to overflow if the packet pointer started in the465 * to overflow if the packet pointer started in the
@@ -467,7 +467,7 @@ static struct bpf_align_test tests[] = { · 1 unmodified line
467 * So we did not get a 'range' on R6, and the access467 * So we did not get a 'range' on R6, and the access
468 * attempt will fail.468 * attempt will fail.
469 */469 */
470 {15, "R6_w=pkt(id=1,off=0,r=0,umin_value=2,umax_value=9223372036854775806,var_off=(0x2; 0x7ffffffffffffffc)"},470 {15, "R6_w=pkt(id=1,off=0,r=0,umin=2,umax=9223372036854775806,var_off=(0x2; 0x7ffffffffffffffc)"},
471 }471 }
472 },472 },
473 {473 {
@@ -502,23 +502,23 @@ static struct bpf_align_test tests[] = { · 28 unmodified lines
502 /* Calculated offset in R6 has unknown value, but known502 /* Calculated offset in R6 has unknown value, but known
503 * alignment of 4.503 * alignment of 4.
504 */504 */
505 {6, "R2_w=pkt(id=0,off=0,r=8,imm=0)"},505 {6, "R2_w=pkt(off=0,r=8,imm=0)"},
506 {8, "R6_w=inv(id=0,umax_value=1020,var_off=(0x0; 0x3fc))"},506 {8, "R6_w=scalar(umax=1020,var_off=(0x0; 0x3fc))"},
507 /* Adding 14 makes R6 be (4n+2) */507 /* Adding 14 makes R6 be (4n+2) */
508 {9, "R6_w=inv(id=0,umin_value=14,umax_value=1034,var_off=(0x2; 0x7fc))"},508 {9, "R6_w=scalar(umin=14,umax=1034,var_off=(0x2; 0x7fc))"},
509 /* New unknown value in R7 is (4n) */509 /* New unknown value in R7 is (4n) */
510 {10, "R7_w=inv(id=0,umax_value=1020,var_off=(0x0; 0x3fc))"},510 {10, "R7_w=scalar(umax=1020,var_off=(0x0; 0x3fc))"},
511 /* Subtracting it from R6 blows our unsigned bounds */511 /* Subtracting it from R6 blows our unsigned bounds */
512 {11, "R6=inv(id=0,smin_value=-1006,smax_value=1034,umin_value=2,umax_value=18446744073709551614,var_off=(0x2; 0xfffffffffffffffc)"},512 {11, "R6=scalar(smin=-1006,smax=1034,umin=2,umax=18446744073709551614,var_off=(0x2; 0xfffffffffffffffc)"},
513 /* Checked s>= 0 */513 /* Checked s>= 0 */
514 {14, "R6=inv(id=0,umin_value=2,umax_value=1034,var_off=(0x2; 0x7fc))"},514 {14, "R6=scalar(umin=2,umax=1034,var_off=(0x2; 0x7fc))"},
515 /* At the time the word size load is performed from R5,515 /* At the time the word size load is performed from R5,
516 * its total fixed offset is NET_IP_ALIGN + reg->off (0)516 * its total fixed offset is NET_IP_ALIGN + reg->off (0)
517 * which is 2. Then the variable offset is (4n+2), so517 * which is 2. Then the variable offset is (4n+2), so
518 * the total offset is 4-byte aligned and meets the518 * the total offset is 4-byte aligned and meets the
519 * load's requirements.519 * load's requirements.
520 */520 */
521 {20, "R5=pkt(id=2,off=0,r=4,umin_value=2,umax_value=1034,var_off=(0x2; 0x7fc)"},521 {20, "R5=pkt(id=2,off=0,r=4,umin=2,umax=1034,var_off=(0x2; 0x7fc)"},
522 522
523 },523 },
524 },524 },
@@ -556,23 +556,23 @@ static struct bpf_align_test tests[] = { · 31 unmodified lines
556 /* Calculated offset in R6 has unknown value, but known556 /* Calculated offset in R6 has unknown value, but known
557 * alignment of 4.557 * alignment of 4.
558 */558 */
559 {6, "R2_w=pkt(id=0,off=0,r=8,imm=0)"},559 {6, "R2_w=pkt(off=0,r=8,imm=0)"},
560 {9, "R6_w=inv(id=0,umax_value=60,var_off=(0x0; 0x3c))"},560 {9, "R6_w=scalar(umax=60,var_off=(0x0; 0x3c))"},
561 /* Adding 14 makes R6 be (4n+2) */561 /* Adding 14 makes R6 be (4n+2) */
562 {10, "R6_w=inv(id=0,umin_value=14,umax_value=74,var_off=(0x2; 0x7c))"},562 {10, "R6_w=scalar(umin=14,umax=74,var_off=(0x2; 0x7c))"},
563 /* Subtracting from packet pointer overflows ubounds */563 /* Subtracting from packet pointer overflows ubounds */
564 {13, "R5_w=pkt(id=2,off=0,r=8,umin_value=18446744073709551542,umax_value=18446744073709551602,var_off=(0xffffffffffffff82; 0x7c)"},564 {13, "R5_w=pkt(id=2,off=0,r=8,umin=18446744073709551542,umax=18446744073709551602,var_off=(0xffffffffffffff82; 0x7c)"},
565 /* New unknown value in R7 is (4n), >= 76 */565 /* New unknown value in R7 is (4n), >= 76 */
566 {14, "R7_w=inv(id=0,umin_value=76,umax_value=1096,var_off=(0x0; 0x7fc))"},566 {14, "R7_w=scalar(umin=76,umax=1096,var_off=(0x0; 0x7fc))"},
567 /* Adding it to packet pointer gives nice bounds again */567 /* Adding it to packet pointer gives nice bounds again */
568 {16, "R5_w=pkt(id=3,off=0,r=0,umin_value=2,umax_value=1082,var_off=(0x2; 0xfffffffc)"},568 {16, "R5_w=pkt(id=3,off=0,r=0,umin=2,umax=1082,var_off=(0x2; 0xfffffffc)"},
569 /* At the time the word size load is performed from R5,569 /* At the time the word size load is performed from R5,
570 * its total fixed offset is NET_IP_ALIGN + reg->off (0)570 * its total fixed offset is NET_IP_ALIGN + reg->off (0)
571 * which is 2. Then the variable offset is (4n+2), so571 * which is 2. Then the variable offset is (4n+2), so
572 * the total offset is 4-byte aligned and meets the572 * the total offset is 4-byte aligned and meets the
573 * load's requirements.573 * load's requirements.
574 */574 */
575 {20, "R5=pkt(id=3,off=0,r=4,umin_value=2,umax_value=1082,var_off=(0x2; 0xfffffffc)"},575 {20, "R5=pkt(id=3,off=0,r=4,umin=2,umax=1082,var_off=(0x2; 0xfffffffc)"},
576 },576 },
577 },577 },
578};578};
@@ -648,8 +648,8 @@ static int do_test_single(struct bpf_align_test *test) · 69 unmodified lines
648 /* Check the next line as well in case the previous line648 /* Check the next line as well in case the previous line
649 * did not have a corresponding bpf insn. Example:649 * did not have a corresponding bpf insn. Example:
650 * func#0 @0650 * func#0 @0
651 * 0: R1=ctx(id=0,off=0,imm=0) R10=fp0651 * 0: R1=ctx(off=0,imm=0) R10=fp0
652 * 0: (b7) r3 = 2 ; R3_w=inv2652 * 0: (b7) r3 = 2 ; R3_w=2
653 */653 */
654 if (!strstr(line_ptr, m.match)) {654 if (!strstr(line_ptr, m.match)) {
655 cur_line = -1;655 cur_line = -1;
tools/testing/selftests/bpf/prog_tests/log_buf.c+2−2
@@ -78,7 +78,7 @@ static void obj_load_log_buf(void) · 77 unmodified lines
78 ASSERT_OK_PTR(strstr(libbpf_log_buf, "prog 'bad_prog': BPF program load failed"),78 ASSERT_OK_PTR(strstr(libbpf_log_buf, "prog 'bad_prog': BPF program load failed"),
79 "libbpf_log_not_empty");79 "libbpf_log_not_empty");
80 ASSERT_OK_PTR(strstr(obj_log_buf, "DATASEC license"), "obj_log_not_empty");80 ASSERT_OK_PTR(strstr(obj_log_buf, "DATASEC license"), "obj_log_not_empty");
81 ASSERT_OK_PTR(strstr(good_log_buf, "0: R1=ctx(id=0,off=0,imm=0) R10=fp0"),81 ASSERT_OK_PTR(strstr(good_log_buf, "0: R1=ctx(off=0,imm=0) R10=fp0"),
82 "good_log_verbose");82 "good_log_verbose");
83 ASSERT_OK_PTR(strstr(bad_log_buf, "invalid access to map value, value_size=16 off=16000 size=4"),83 ASSERT_OK_PTR(strstr(bad_log_buf, "invalid access to map value, value_size=16 off=16000 size=4"),
84 "bad_log_not_empty");84 "bad_log_not_empty");
@@ -175,7 +175,7 @@ static void bpf_prog_load_log_buf(void) · 90 unmodified lines
175 opts.log_level = 2;175 opts.log_level = 2;
176 fd = bpf_prog_load(BPF_PROG_TYPE_SOCKET_FILTER, "good_prog", "GPL",176 fd = bpf_prog_load(BPF_PROG_TYPE_SOCKET_FILTER, "good_prog", "GPL",
177 good_prog_insns, good_prog_insn_cnt, &opts);177 good_prog_insns, good_prog_insn_cnt, &opts);
178 ASSERT_OK_PTR(strstr(log_buf, "0: R1=ctx(id=0,off=0,imm=0) R10=fp0"), "good_log_2");178 ASSERT_OK_PTR(strstr(log_buf, "0: R1=ctx(off=0,imm=0) R10=fp0"), "good_log_2");
179 ASSERT_GE(fd, 0, "good_fd2");179 ASSERT_GE(fd, 0, "good_fd2");
180 if (fd >= 0)180 if (fd >= 0)
181 close(fd);181 close(fd);
tools/testing/selftests/bpf/verifier/atomic_invalid.c+3−3
@@ -1,6 +1,6 @@
1#define __INVALID_ATOMIC_ACCESS_TEST(op) \1#define __INVALID_ATOMIC_ACCESS_TEST(op) \
2 { \2 { \
3 "atomic " #op " access through non-pointer ", \3 "atomic " #op " access through non-pointer ", \
4 .insns = { \4 .insns = { \
5 BPF_MOV64_IMM(BPF_REG_0, 1), \5 BPF_MOV64_IMM(BPF_REG_0, 1), \
6 BPF_MOV64_IMM(BPF_REG_1, 0), \6 BPF_MOV64_IMM(BPF_REG_1, 0), \
@@ -9,7 +9,7 @@ · 2 unmodified lines
9 BPF_EXIT_INSN(), \9 BPF_EXIT_INSN(), \
10 }, \10 }, \
11 .result = REJECT, \11 .result = REJECT, \
12 .errstr = "R1 invalid mem access 'inv'" \12 .errstr = "R1 invalid mem access 'scalar'" \
13 }13 }
14__INVALID_ATOMIC_ACCESS_TEST(BPF_ADD),14__INVALID_ATOMIC_ACCESS_TEST(BPF_ADD),
15__INVALID_ATOMIC_ACCESS_TEST(BPF_ADD | BPF_FETCH),15__INVALID_ATOMIC_ACCESS_TEST(BPF_ADD | BPF_FETCH),
tools/testing/selftests/bpf/verifier/bounds.c+2−2
@@ -508,7 +508,7 @@ · 507 unmodified lines
508 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_0, -1),508 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_0, -1),
509 BPF_EXIT_INSN(),509 BPF_EXIT_INSN(),
510 },510 },
511 .errstr_unpriv = "R0 invalid mem access 'inv'",511 .errstr_unpriv = "R0 invalid mem access 'scalar'",
512 .result_unpriv = REJECT,512 .result_unpriv = REJECT,
513 .result = ACCEPT513 .result = ACCEPT
514},514},
@@ -530,7 +530,7 @@ · 15 unmodified lines
530 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_0, -1),530 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_0, -1),
531 BPF_EXIT_INSN(),531 BPF_EXIT_INSN(),
532 },532 },
533 .errstr_unpriv = "R0 invalid mem access 'inv'",533 .errstr_unpriv = "R0 invalid mem access 'scalar'",
534 .result_unpriv = REJECT,534 .result_unpriv = REJECT,
535 .result = ACCEPT535 .result = ACCEPT
536},536},
tools/testing/selftests/bpf/verifier/calls.c+3−3
@@ -188,7 +188,7 @@ · 187 unmodified lines
188 },188 },
189 .prog_type = BPF_PROG_TYPE_SCHED_CLS,189 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
190 .result = REJECT,190 .result = REJECT,
191 .errstr = "R0 invalid mem access 'inv'",191 .errstr = "R0 invalid mem access 'scalar'",
192},192},
193{193{
194 "calls: multiple ret types in subprog 2",194 "calls: multiple ret types in subprog 2",
@@ -491,7 +491,7 @@ · 296 unmodified lines
491 BPF_EXIT_INSN(),491 BPF_EXIT_INSN(),
492 },492 },
493 .result = REJECT,493 .result = REJECT,
494 .errstr = "R6 invalid mem access 'inv'",494 .errstr = "R6 invalid mem access 'scalar'",
495 .prog_type = BPF_PROG_TYPE_XDP,495 .prog_type = BPF_PROG_TYPE_XDP,
496 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,496 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
497},497},
@@ -1697,7 +1697,7 @@ · 1199 unmodified lines
1697 .prog_type = BPF_PROG_TYPE_SCHED_CLS,1697 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
1698 .fixup_map_hash_8b = { 12, 22 },1698 .fixup_map_hash_8b = { 12, 22 },
1699 .result = REJECT,1699 .result = REJECT,
1700 .errstr = "R0 invalid mem access 'inv'",1700 .errstr = "R0 invalid mem access 'scalar'",
1701},1701},
1702{1702{
1703 "calls: pkt_ptr spill into caller stack",1703 "calls: pkt_ptr spill into caller stack",
tools/testing/selftests/bpf/verifier/ctx.c+2−2
@@ -127,7 +127,7 @@ · 126 unmodified lines
127 .prog_type = BPF_PROG_TYPE_CGROUP_SOCK_ADDR,127 .prog_type = BPF_PROG_TYPE_CGROUP_SOCK_ADDR,
128 .expected_attach_type = BPF_CGROUP_UDP6_SENDMSG,128 .expected_attach_type = BPF_CGROUP_UDP6_SENDMSG,
129 .result = REJECT,129 .result = REJECT,
130 .errstr = "R1 type=inv expected=ctx",130 .errstr = "R1 type=scalar expected=ctx",
131},131},
132{132{
133 "pass ctx or null check, 4: ctx - const",133 "pass ctx or null check, 4: ctx - const",
@@ -193,5 +193,5 @@ · 59 unmodified lines
193 .prog_type = BPF_PROG_TYPE_CGROUP_SOCK,193 .prog_type = BPF_PROG_TYPE_CGROUP_SOCK,
194 .expected_attach_type = BPF_CGROUP_INET4_POST_BIND,194 .expected_attach_type = BPF_CGROUP_INET4_POST_BIND,
195 .result = REJECT,195 .result = REJECT,
196 .errstr = "R1 type=inv expected=ctx",196 .errstr = "R1 type=scalar expected=ctx",
197},197},
tools/testing/selftests/bpf/verifier/direct_packet_access.c+1−1
@@ -339,7 +339,7 @@ · 338 unmodified lines
339 BPF_MOV64_IMM(BPF_REG_0, 0),339 BPF_MOV64_IMM(BPF_REG_0, 0),
340 BPF_EXIT_INSN(),340 BPF_EXIT_INSN(),
341 },341 },
342 .errstr = "R2 invalid mem access 'inv'",342 .errstr = "R2 invalid mem access 'scalar'",
343 .result = REJECT,343 .result = REJECT,
344 .prog_type = BPF_PROG_TYPE_SCHED_CLS,344 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
345 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,345 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
tools/testing/selftests/bpf/verifier/helper_access_var_len.c+3−3
@@ -350,7 +350,7 @@ · 349 unmodified lines
350 BPF_EMIT_CALL(BPF_FUNC_csum_diff),350 BPF_EMIT_CALL(BPF_FUNC_csum_diff),
351 BPF_EXIT_INSN(),351 BPF_EXIT_INSN(),
352 },352 },
353 .errstr = "R1 type=inv expected=fp",353 .errstr = "R1 type=scalar expected=fp",
354 .result = REJECT,354 .result = REJECT,
355 .prog_type = BPF_PROG_TYPE_SCHED_CLS,355 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
356},356},
@@ -471,7 +471,7 @@ · 114 unmodified lines
471 BPF_EMIT_CALL(BPF_FUNC_probe_read_kernel),471 BPF_EMIT_CALL(BPF_FUNC_probe_read_kernel),
472 BPF_EXIT_INSN(),472 BPF_EXIT_INSN(),
473 },473 },
474 .errstr = "R1 type=inv expected=fp",474 .errstr = "R1 type=scalar expected=fp",
475 .result = REJECT,475 .result = REJECT,
476 .prog_type = BPF_PROG_TYPE_TRACEPOINT,476 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
477},477},
@@ -484,7 +484,7 @@ · 6 unmodified lines
484 BPF_EMIT_CALL(BPF_FUNC_probe_read_kernel),484 BPF_EMIT_CALL(BPF_FUNC_probe_read_kernel),
485 BPF_EXIT_INSN(),485 BPF_EXIT_INSN(),
486 },486 },
487 .errstr = "R1 type=inv expected=fp",487 .errstr = "R1 type=scalar expected=fp",
488 .result = REJECT,488 .result = REJECT,
489 .prog_type = BPF_PROG_TYPE_TRACEPOINT,489 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
490},490},
tools/testing/selftests/bpf/verifier/jmp32.c+8−8
@@ -286,7 +286,7 @@ · 285 unmodified lines
286 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_0, 0),286 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_0, 0),
287 BPF_EXIT_INSN(),287 BPF_EXIT_INSN(),
288 },288 },
289 .errstr_unpriv = "R0 invalid mem access 'inv'",289 .errstr_unpriv = "R0 invalid mem access 'scalar'",
290 .result_unpriv = REJECT,290 .result_unpriv = REJECT,
291 .result = ACCEPT,291 .result = ACCEPT,
292 .retval = 2,292 .retval = 2,
@@ -356,7 +356,7 @@ · 63 unmodified lines
356 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_0, 0),356 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_0, 0),
357 BPF_EXIT_INSN(),357 BPF_EXIT_INSN(),
358 },358 },
359 .errstr_unpriv = "R0 invalid mem access 'inv'",359 .errstr_unpriv = "R0 invalid mem access 'scalar'",
360 .result_unpriv = REJECT,360 .result_unpriv = REJECT,
361 .result = ACCEPT,361 .result = ACCEPT,
362 .retval = 2,362 .retval = 2,
@@ -426,7 +426,7 @@ · 63 unmodified lines
426 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_0, 0),426 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_0, 0),
427 BPF_EXIT_INSN(),427 BPF_EXIT_INSN(),
428 },428 },
429 .errstr_unpriv = "R0 invalid mem access 'inv'",429 .errstr_unpriv = "R0 invalid mem access 'scalar'",
430 .result_unpriv = REJECT,430 .result_unpriv = REJECT,
431 .result = ACCEPT,431 .result = ACCEPT,
432 .retval = 2,432 .retval = 2,
@@ -496,7 +496,7 @@ · 63 unmodified lines
496 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_0, 0),496 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_0, 0),
497 BPF_EXIT_INSN(),497 BPF_EXIT_INSN(),
498 },498 },
499 .errstr_unpriv = "R0 invalid mem access 'inv'",499 .errstr_unpriv = "R0 invalid mem access 'scalar'",
500 .result_unpriv = REJECT,500 .result_unpriv = REJECT,
501 .result = ACCEPT,501 .result = ACCEPT,
502 .retval = 2,502 .retval = 2,
@@ -566,7 +566,7 @@ · 63 unmodified lines
566 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_0, 0),566 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_0, 0),
567 BPF_EXIT_INSN(),567 BPF_EXIT_INSN(),
568 },568 },
569 .errstr_unpriv = "R0 invalid mem access 'inv'",569 .errstr_unpriv = "R0 invalid mem access 'scalar'",
570 .result_unpriv = REJECT,570 .result_unpriv = REJECT,
571 .result = ACCEPT,571 .result = ACCEPT,
572 .retval = 2,572 .retval = 2,
@@ -636,7 +636,7 @@ · 63 unmodified lines
636 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_0, 0),636 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_0, 0),
637 BPF_EXIT_INSN(),637 BPF_EXIT_INSN(),
638 },638 },
639 .errstr_unpriv = "R0 invalid mem access 'inv'",639 .errstr_unpriv = "R0 invalid mem access 'scalar'",
640 .result_unpriv = REJECT,640 .result_unpriv = REJECT,
641 .result = ACCEPT,641 .result = ACCEPT,
642 .retval = 2,642 .retval = 2,
@@ -706,7 +706,7 @@ · 63 unmodified lines
706 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_0, 0),706 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_0, 0),
707 BPF_EXIT_INSN(),707 BPF_EXIT_INSN(),
708 },708 },
709 .errstr_unpriv = "R0 invalid mem access 'inv'",709 .errstr_unpriv = "R0 invalid mem access 'scalar'",
710 .result_unpriv = REJECT,710 .result_unpriv = REJECT,
711 .result = ACCEPT,711 .result = ACCEPT,
712 .retval = 2,712 .retval = 2,
@@ -776,7 +776,7 @@ · 63 unmodified lines
776 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_0, 0),776 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_0, 0),
777 BPF_EXIT_INSN(),777 BPF_EXIT_INSN(),
778 },778 },
779 .errstr_unpriv = "R0 invalid mem access 'inv'",779 .errstr_unpriv = "R0 invalid mem access 'scalar'",
780 .result_unpriv = REJECT,780 .result_unpriv = REJECT,
781 .result = ACCEPT,781 .result = ACCEPT,
782 .retval = 2,782 .retval = 2,
tools/testing/selftests/bpf/verifier/precise.c+2−2
@@ -27,7 +27,7 @@ · 26 unmodified lines
27 BPF_JMP_IMM(BPF_JLT, BPF_REG_2, 8, 1),27 BPF_JMP_IMM(BPF_JLT, BPF_REG_2, 8, 1),
28 BPF_EXIT_INSN(),28 BPF_EXIT_INSN(),
29 29
30 BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, 1), /* R2=inv(umin=1, umax=8) */30 BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, 1), /* R2=scalar(umin=1, umax=8) */
31 BPF_MOV64_REG(BPF_REG_1, BPF_REG_FP),31 BPF_MOV64_REG(BPF_REG_1, BPF_REG_FP),
32 BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, -8),32 BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, -8),
33 BPF_MOV64_IMM(BPF_REG_3, 0),33 BPF_MOV64_IMM(BPF_REG_3, 0),
@@ -87,7 +87,7 @@ · 53 unmodified lines
87 BPF_JMP_IMM(BPF_JLT, BPF_REG_2, 8, 1),87 BPF_JMP_IMM(BPF_JLT, BPF_REG_2, 8, 1),
88 BPF_EXIT_INSN(),88 BPF_EXIT_INSN(),
89 89
90 BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, 1), /* R2=inv(umin=1, umax=8) */90 BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, 1), /* R2=scalar(umin=1, umax=8) */
91 BPF_MOV64_REG(BPF_REG_1, BPF_REG_FP),91 BPF_MOV64_REG(BPF_REG_1, BPF_REG_FP),
92 BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, -8),92 BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, -8),
93 BPF_MOV64_IMM(BPF_REG_3, 0),93 BPF_MOV64_IMM(BPF_REG_3, 0),
tools/testing/selftests/bpf/verifier/raw_stack.c+2−2
@@ -132,7 +132,7 @@ · 131 unmodified lines
132 BPF_EXIT_INSN(),132 BPF_EXIT_INSN(),
133 },133 },
134 .result = REJECT,134 .result = REJECT,
135 .errstr = "R0 invalid mem access 'inv'",135 .errstr = "R0 invalid mem access 'scalar'",
136 .prog_type = BPF_PROG_TYPE_SCHED_CLS,136 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
137 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,137 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
138},138},
@@ -162,7 +162,7 @@ · 23 unmodified lines
162 BPF_EXIT_INSN(),162 BPF_EXIT_INSN(),
163 },163 },
164 .result = REJECT,164 .result = REJECT,
165 .errstr = "R3 invalid mem access 'inv'",165 .errstr = "R3 invalid mem access 'scalar'",
166 .prog_type = BPF_PROG_TYPE_SCHED_CLS,166 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
167 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,167 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
168},168},
tools/testing/selftests/bpf/verifier/ref_tracking.c+3−3
@@ -162,7 +162,7 @@ · 161 unmodified lines
162 BPF_EXIT_INSN(),162 BPF_EXIT_INSN(),
163 },163 },
164 .prog_type = BPF_PROG_TYPE_SCHED_CLS,164 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
165 .errstr = "type=inv expected=sock",165 .errstr = "type=scalar expected=sock",
166 .result = REJECT,166 .result = REJECT,
167},167},
168{168{
@@ -178,7 +178,7 @@ · 9 unmodified lines
178 BPF_EXIT_INSN(),178 BPF_EXIT_INSN(),
179 },179 },
180 .prog_type = BPF_PROG_TYPE_SCHED_CLS,180 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
181 .errstr = "type=inv expected=sock",181 .errstr = "type=scalar expected=sock",
182 .result = REJECT,182 .result = REJECT,
183},183},
184{184{
@@ -274,7 +274,7 @@ · 89 unmodified lines
274 BPF_EXIT_INSN(),274 BPF_EXIT_INSN(),
275 },275 },
276 .prog_type = BPF_PROG_TYPE_SCHED_CLS,276 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
277 .errstr = "type=inv expected=sock",277 .errstr = "type=scalar expected=sock",
278 .result = REJECT,278 .result = REJECT,
279},279},
280{280{
tools/testing/selftests/bpf/verifier/search_pruning.c+1−1
@@ -104,7 +104,7 @@ · 103 unmodified lines
104 BPF_EXIT_INSN(),104 BPF_EXIT_INSN(),
105 },105 },
106 .fixup_map_hash_8b = { 3 },106 .fixup_map_hash_8b = { 3 },
107 .errstr = "R6 invalid mem access 'inv'",107 .errstr = "R6 invalid mem access 'scalar'",
108 .result = REJECT,108 .result = REJECT,
109 .prog_type = BPF_PROG_TYPE_TRACEPOINT,109 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
110},110},
tools/testing/selftests/bpf/verifier/sock.c+1−1
@@ -502,7 +502,7 @@ · 501 unmodified lines
502 .fixup_sk_storage_map = { 11 },502 .fixup_sk_storage_map = { 11 },
503 .prog_type = BPF_PROG_TYPE_SCHED_CLS,503 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
504 .result = REJECT,504 .result = REJECT,
505 .errstr = "R3 type=inv expected=fp",505 .errstr = "R3 type=scalar expected=fp",
506},506},
507{507{
508 "sk_storage_get(map, skb->sk, &stack_value, 1): stack_value",508 "sk_storage_get(map, skb->sk, &stack_value, 1): stack_value",
tools/testing/selftests/bpf/verifier/spill_fill.c+19−19
@@ -102,7 +102,7 @@ · 101 unmodified lines
102 BPF_EXIT_INSN(),102 BPF_EXIT_INSN(),
103 },103 },
104 .errstr_unpriv = "attempt to corrupt spilled",104 .errstr_unpriv = "attempt to corrupt spilled",
105 .errstr = "R0 invalid mem access 'inv",105 .errstr = "R0 invalid mem access 'scalar'",
106 .result = REJECT,106 .result = REJECT,
107 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,107 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
108},108},
@@ -147,11 +147,11 @@ · 38 unmodified lines
147 BPF_LDX_MEM(BPF_W, BPF_REG_4, BPF_REG_10, -8),147 BPF_LDX_MEM(BPF_W, BPF_REG_4, BPF_REG_10, -8),
148 /* r0 = r2 */148 /* r0 = r2 */
149 BPF_MOV64_REG(BPF_REG_0, BPF_REG_2),149 BPF_MOV64_REG(BPF_REG_0, BPF_REG_2),
150 /* r0 += r4 R0=pkt R2=pkt R3=pkt_end R4=inv20 */150 /* r0 += r4 R0=pkt R2=pkt R3=pkt_end R4=20 */
151 BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_4),151 BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_4),
152 /* if (r0 > r3) R0=pkt,off=20 R2=pkt R3=pkt_end R4=inv20 */152 /* if (r0 > r3) R0=pkt,off=20 R2=pkt R3=pkt_end R4=20 */
153 BPF_JMP_REG(BPF_JGT, BPF_REG_0, BPF_REG_3, 1),153 BPF_JMP_REG(BPF_JGT, BPF_REG_0, BPF_REG_3, 1),
154 /* r0 = *(u32 *)r2 R0=pkt,off=20,r=20 R2=pkt,r=20 R3=pkt_end R4=inv20 */154 /* r0 = *(u32 *)r2 R0=pkt,off=20,r=20 R2=pkt,r=20 R3=pkt_end R4=20 */
155 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_2, 0),155 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_2, 0),
156 BPF_MOV64_IMM(BPF_REG_0, 0),156 BPF_MOV64_IMM(BPF_REG_0, 0),
157 BPF_EXIT_INSN(),157 BPF_EXIT_INSN(),
@@ -190,11 +190,11 @@ · 32 unmodified lines
190 BPF_LDX_MEM(BPF_H, BPF_REG_4, BPF_REG_10, -8),190 BPF_LDX_MEM(BPF_H, BPF_REG_4, BPF_REG_10, -8),
191 /* r0 = r2 */191 /* r0 = r2 */
192 BPF_MOV64_REG(BPF_REG_0, BPF_REG_2),192 BPF_MOV64_REG(BPF_REG_0, BPF_REG_2),
193 /* r0 += r4 R0=pkt R2=pkt R3=pkt_end R4=inv,umax=65535 */193 /* r0 += r4 R0=pkt R2=pkt R3=pkt_end R4=umax=65535 */
194 BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_4),194 BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_4),
195 /* if (r0 > r3) R0=pkt,umax=65535 R2=pkt R3=pkt_end R4=inv,umax=65535 */195 /* if (r0 > r3) R0=pkt,umax=65535 R2=pkt R3=pkt_end R4=umax=65535 */
196 BPF_JMP_REG(BPF_JGT, BPF_REG_0, BPF_REG_3, 1),196 BPF_JMP_REG(BPF_JGT, BPF_REG_0, BPF_REG_3, 1),
197 /* r0 = *(u32 *)r2 R0=pkt,umax=65535 R2=pkt R3=pkt_end R4=inv20 */197 /* r0 = *(u32 *)r2 R0=pkt,umax=65535 R2=pkt R3=pkt_end R4=20 */
198 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_2, 0),198 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_2, 0),
199 BPF_MOV64_IMM(BPF_REG_0, 0),199 BPF_MOV64_IMM(BPF_REG_0, 0),
200 BPF_EXIT_INSN(),200 BPF_EXIT_INSN(),
@@ -222,11 +222,11 @@ · 21 unmodified lines
222 BPF_LDX_MEM(BPF_H, BPF_REG_4, BPF_REG_10, -8),222 BPF_LDX_MEM(BPF_H, BPF_REG_4, BPF_REG_10, -8),
223 /* r0 = r2 */223 /* r0 = r2 */
224 BPF_MOV64_REG(BPF_REG_0, BPF_REG_2),224 BPF_MOV64_REG(BPF_REG_0, BPF_REG_2),
225 /* r0 += r4 R0=pkt R2=pkt R3=pkt_end R4=inv,umax=65535 */225 /* r0 += r4 R0=pkt R2=pkt R3=pkt_end R4=umax=65535 */
226 BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_4),226 BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_4),
227 /* if (r0 > r3) R0=pkt,umax=65535 R2=pkt R3=pkt_end R4=inv,umax=65535 */227 /* if (r0 > r3) R0=pkt,umax=65535 R2=pkt R3=pkt_end R4=umax=65535 */
228 BPF_JMP_REG(BPF_JGT, BPF_REG_0, BPF_REG_3, 1),228 BPF_JMP_REG(BPF_JGT, BPF_REG_0, BPF_REG_3, 1),
229 /* r0 = *(u32 *)r2 R0=pkt,umax=65535 R2=pkt R3=pkt_end R4=inv20 */229 /* r0 = *(u32 *)r2 R0=pkt,umax=65535 R2=pkt R3=pkt_end R4=20 */
230 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_2, 0),230 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_2, 0),
231 BPF_MOV64_IMM(BPF_REG_0, 0),231 BPF_MOV64_IMM(BPF_REG_0, 0),
232 BPF_EXIT_INSN(),232 BPF_EXIT_INSN(),
@@ -250,11 +250,11 @@ · 17 unmodified lines
250 BPF_LDX_MEM(BPF_H, BPF_REG_4, BPF_REG_10, -6),250 BPF_LDX_MEM(BPF_H, BPF_REG_4, BPF_REG_10, -6),
251 /* r0 = r2 */251 /* r0 = r2 */
252 BPF_MOV64_REG(BPF_REG_0, BPF_REG_2),252 BPF_MOV64_REG(BPF_REG_0, BPF_REG_2),
253 /* r0 += r4 R0=pkt R2=pkt R3=pkt_end R4=inv,umax=65535 */253 /* r0 += r4 R0=pkt R2=pkt R3=pkt_end R4=umax=65535 */
254 BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_4),254 BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_4),
255 /* if (r0 > r3) R0=pkt,umax=65535 R2=pkt R3=pkt_end R4=inv,umax=65535 */255 /* if (r0 > r3) R0=pkt,umax=65535 R2=pkt R3=pkt_end R4=umax=65535 */
256 BPF_JMP_REG(BPF_JGT, BPF_REG_0, BPF_REG_3, 1),256 BPF_JMP_REG(BPF_JGT, BPF_REG_0, BPF_REG_3, 1),
257 /* r0 = *(u32 *)r2 R0=pkt,umax=65535 R2=pkt R3=pkt_end R4=inv20 */257 /* r0 = *(u32 *)r2 R0=pkt,umax=65535 R2=pkt R3=pkt_end R4=20 */
258 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_2, 0),258 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_2, 0),
259 BPF_MOV64_IMM(BPF_REG_0, 0),259 BPF_MOV64_IMM(BPF_REG_0, 0),
260 BPF_EXIT_INSN(),260 BPF_EXIT_INSN(),
@@ -280,11 +280,11 @@ · 19 unmodified lines
280 BPF_LDX_MEM(BPF_W, BPF_REG_4, BPF_REG_10, -4),280 BPF_LDX_MEM(BPF_W, BPF_REG_4, BPF_REG_10, -4),
281 /* r0 = r2 */281 /* r0 = r2 */
282 BPF_MOV64_REG(BPF_REG_0, BPF_REG_2),282 BPF_MOV64_REG(BPF_REG_0, BPF_REG_2),
283 /* r0 += r4 R0=pkt R2=pkt R3=pkt_end R4=inv,umax=U32_MAX */283 /* r0 += r4 R0=pkt R2=pkt R3=pkt_end R4=umax=U32_MAX */
284 BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_4),284 BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_4),
285 /* if (r0 > r3) R0=pkt,umax=U32_MAX R2=pkt R3=pkt_end R4=inv */285 /* if (r0 > r3) R0=pkt,umax=U32_MAX R2=pkt R3=pkt_end R4= */
286 BPF_JMP_REG(BPF_JGT, BPF_REG_0, BPF_REG_3, 1),286 BPF_JMP_REG(BPF_JGT, BPF_REG_0, BPF_REG_3, 1),
287 /* r0 = *(u32 *)r2 R0=pkt,umax=U32_MAX R2=pkt R3=pkt_end R4=inv */287 /* r0 = *(u32 *)r2 R0=pkt,umax=U32_MAX R2=pkt R3=pkt_end R4= */
288 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_2, 0),288 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_2, 0),
289 BPF_MOV64_IMM(BPF_REG_0, 0),289 BPF_MOV64_IMM(BPF_REG_0, 0),
290 BPF_EXIT_INSN(),290 BPF_EXIT_INSN(),
@@ -305,13 +305,13 @@ · 14 unmodified lines
305 BPF_JMP_IMM(BPF_JLE, BPF_REG_4, 40, 2),305 BPF_JMP_IMM(BPF_JLE, BPF_REG_4, 40, 2),
306 BPF_MOV64_IMM(BPF_REG_0, 0),306 BPF_MOV64_IMM(BPF_REG_0, 0),
307 BPF_EXIT_INSN(),307 BPF_EXIT_INSN(),
308 /* *(u32 *)(r10 -8) = r4 R4=inv,umax=40 */308 /* *(u32 *)(r10 -8) = r4 R4=umax=40 */
309 BPF_STX_MEM(BPF_W, BPF_REG_10, BPF_REG_4, -8),309 BPF_STX_MEM(BPF_W, BPF_REG_10, BPF_REG_4, -8),
310 /* r4 = (*u32 *)(r10 - 8) */310 /* r4 = (*u32 *)(r10 - 8) */
311 BPF_LDX_MEM(BPF_W, BPF_REG_4, BPF_REG_10, -8),311 BPF_LDX_MEM(BPF_W, BPF_REG_4, BPF_REG_10, -8),
312 /* r2 += r4 R2=pkt R4=inv,umax=40 */312 /* r2 += r4 R2=pkt R4=umax=40 */
313 BPF_ALU64_REG(BPF_ADD, BPF_REG_2, BPF_REG_4),313 BPF_ALU64_REG(BPF_ADD, BPF_REG_2, BPF_REG_4),
314 /* r0 = r2 R2=pkt,umax=40 R4=inv,umax=40 */314 /* r0 = r2 R2=pkt,umax=40 R4=umax=40 */
315 BPF_MOV64_REG(BPF_REG_0, BPF_REG_2),315 BPF_MOV64_REG(BPF_REG_0, BPF_REG_2),
316 /* r2 += 20 R0=pkt,umax=40 R2=pkt,umax=40 */316 /* r2 += 20 R0=pkt,umax=40 R2=pkt,umax=40 */
317 BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, 20),317 BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, 20),
tools/testing/selftests/bpf/verifier/unpriv.c+2−2
@@ -214,7 +214,7 @@ · 213 unmodified lines
214 BPF_EXIT_INSN(),214 BPF_EXIT_INSN(),
215 },215 },
216 .result = REJECT,216 .result = REJECT,
217 .errstr = "R1 type=inv expected=ctx",217 .errstr = "R1 type=scalar expected=ctx",
218 .prog_type = BPF_PROG_TYPE_SCHED_CLS,218 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
219},219},
220{220{
@@ -420,7 +420,7 @@ · 199 unmodified lines
420 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_7, 0),420 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_7, 0),
421 BPF_EXIT_INSN(),421 BPF_EXIT_INSN(),
422 },422 },
423 .errstr_unpriv = "R7 invalid mem access 'inv'",423 .errstr_unpriv = "R7 invalid mem access 'scalar'",
424 .result_unpriv = REJECT,424 .result_unpriv = REJECT,
425 .result = ACCEPT,425 .result = ACCEPT,
426 .retval = 0,426 .retval = 0,
tools/testing/selftests/bpf/verifier/value_illegal_alu.c+2−2
@@ -64,7 +64,7 @@ · 63 unmodified lines
64 },64 },
65 .fixup_map_hash_48b = { 3 },65 .fixup_map_hash_48b = { 3 },
66 .errstr_unpriv = "R0 pointer arithmetic prohibited",66 .errstr_unpriv = "R0 pointer arithmetic prohibited",
67 .errstr = "invalid mem access 'inv'",67 .errstr = "invalid mem access 'scalar'",
68 .result = REJECT,68 .result = REJECT,
69 .result_unpriv = REJECT,69 .result_unpriv = REJECT,
70 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,70 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
@@ -89,7 +89,7 @@ · 18 unmodified lines
89 },89 },
90 .fixup_map_hash_48b = { 3 },90 .fixup_map_hash_48b = { 3 },
91 .errstr_unpriv = "leaking pointer from stack off -8",91 .errstr_unpriv = "leaking pointer from stack off -8",
92 .errstr = "R0 invalid mem access 'inv'",92 .errstr = "R0 invalid mem access 'scalar'",
93 .result = REJECT,93 .result = REJECT,
94 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,94 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
95},95},
tools/testing/selftests/bpf/verifier/value_ptr_arith.c+2−2
@@ -397,7 +397,7 @@ · 396 unmodified lines
397 .fixup_map_array_48b = { 1 },397 .fixup_map_array_48b = { 1 },
398 .result = ACCEPT,398 .result = ACCEPT,
399 .result_unpriv = REJECT,399 .result_unpriv = REJECT,
400 .errstr_unpriv = "R0 invalid mem access 'inv'",400 .errstr_unpriv = "R0 invalid mem access 'scalar'",
401 .retval = 0,401 .retval = 0,
402},402},
403{403{
@@ -1074,7 +1074,7 @@ · 670 unmodified lines
1074 },1074 },
1075 .fixup_map_array_48b = { 3 },1075 .fixup_map_array_48b = { 3 },
1076 .result = REJECT,1076 .result = REJECT,
1077 .errstr = "R0 invalid mem access 'inv'",1077 .errstr = "R0 invalid mem access 'scalar'",
1078 .errstr_unpriv = "R0 pointer -= pointer prohibited",1078 .errstr_unpriv = "R0 pointer -= pointer prohibited",
1079},1079},
1080{1080{
tools/testing/selftests/bpf/verifier/var_off.c+1−1
@@ -131,7 +131,7 @@ · 130 unmodified lines
131 * write might have overwritten the spilled pointer (i.e. we lose track131 * write might have overwritten the spilled pointer (i.e. we lose track
132 * of the spilled register when we analyze the write).132 * of the spilled register when we analyze the write).
133 */133 */
134 .errstr = "R2 invalid mem access 'inv'",134 .errstr = "R2 invalid mem access 'scalar'",
135 .result = REJECT,135 .result = REJECT,
136},136},
137{137{