bpf: Update selftests to reflect new error states
commit d7a5091351756d0ae8e63134313c455624e36a13 upstream Update various selftest error messages: * The 'Rx tried to sub from different maps, paths, or prohibited types' is reworked into more specific/differentiated error messages for better guidance. * The change into 'value -4294967168 makes map_value pointer be out of bounds' is due to moving the mixed bounds check into the speculation handling and thus occuring slightly later than above mentioned sanity check. * The change into 'math between map_value pointer and register with unbounded min value' is similarly due to register sanity check coming before the mixed bounds check. * The case of 'map access: known scalar += value_ptr from different maps' now loads fine given masks are the same from the different paths (despite max map value size being different). Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Reviewed-by: John Fastabend <john.fastabend@gmail.com> Acked-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
360e5b7af6
commit
98bf2906d3
@@ -261,8 +261,6 @@
|
|||||||
},
|
},
|
||||||
.fixup_map_hash_8b = { 3 },
|
.fixup_map_hash_8b = { 3 },
|
||||||
/* not actually fully unbounded, but the bound is very high */
|
/* not actually fully unbounded, but the bound is very high */
|
||||||
.errstr_unpriv = "R1 has unknown scalar with mixed signed bounds, pointer arithmetic with it prohibited for !root",
|
|
||||||
.result_unpriv = REJECT,
|
|
||||||
.errstr = "value -4294967168 makes map_value pointer be out of bounds",
|
.errstr = "value -4294967168 makes map_value pointer be out of bounds",
|
||||||
.result = REJECT,
|
.result = REJECT,
|
||||||
},
|
},
|
||||||
@@ -298,9 +296,6 @@
|
|||||||
BPF_EXIT_INSN(),
|
BPF_EXIT_INSN(),
|
||||||
},
|
},
|
||||||
.fixup_map_hash_8b = { 3 },
|
.fixup_map_hash_8b = { 3 },
|
||||||
/* not actually fully unbounded, but the bound is very high */
|
|
||||||
.errstr_unpriv = "R1 has unknown scalar with mixed signed bounds, pointer arithmetic with it prohibited for !root",
|
|
||||||
.result_unpriv = REJECT,
|
|
||||||
.errstr = "value -4294967168 makes map_value pointer be out of bounds",
|
.errstr = "value -4294967168 makes map_value pointer be out of bounds",
|
||||||
.result = REJECT,
|
.result = REJECT,
|
||||||
},
|
},
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_1),
|
BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_1),
|
||||||
BPF_EXIT_INSN(),
|
BPF_EXIT_INSN(),
|
||||||
},
|
},
|
||||||
.errstr_unpriv = "R0 tried to sub from different maps, paths, or prohibited types",
|
.errstr_unpriv = "R1 has pointer with unsupported alu operation",
|
||||||
.errstr = "R0 tried to subtract pointer from scalar",
|
.errstr = "R0 tried to subtract pointer from scalar",
|
||||||
.result = REJECT,
|
.result = REJECT,
|
||||||
},
|
},
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
BPF_ALU64_REG(BPF_SUB, BPF_REG_1, BPF_REG_0),
|
BPF_ALU64_REG(BPF_SUB, BPF_REG_1, BPF_REG_0),
|
||||||
BPF_EXIT_INSN(),
|
BPF_EXIT_INSN(),
|
||||||
},
|
},
|
||||||
.errstr_unpriv = "R1 tried to sub from different maps, paths, or prohibited types",
|
.errstr_unpriv = "R1 has pointer with unsupported alu operation",
|
||||||
.result_unpriv = REJECT,
|
.result_unpriv = REJECT,
|
||||||
.result = ACCEPT,
|
.result = ACCEPT,
|
||||||
.retval = 1,
|
.retval = 1,
|
||||||
@@ -34,22 +34,23 @@
|
|||||||
BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_1),
|
BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_1),
|
||||||
BPF_EXIT_INSN(),
|
BPF_EXIT_INSN(),
|
||||||
},
|
},
|
||||||
.errstr_unpriv = "R0 tried to sub from different maps, paths, or prohibited types",
|
.errstr_unpriv = "R1 has pointer with unsupported alu operation",
|
||||||
.errstr = "R0 tried to subtract pointer from scalar",
|
.errstr = "R0 tried to subtract pointer from scalar",
|
||||||
.result = REJECT,
|
.result = REJECT,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"check deducing bounds from const, 4",
|
"check deducing bounds from const, 4",
|
||||||
.insns = {
|
.insns = {
|
||||||
|
BPF_MOV64_REG(BPF_REG_6, BPF_REG_1),
|
||||||
BPF_MOV64_IMM(BPF_REG_0, 0),
|
BPF_MOV64_IMM(BPF_REG_0, 0),
|
||||||
BPF_JMP_IMM(BPF_JSLE, BPF_REG_0, 0, 1),
|
BPF_JMP_IMM(BPF_JSLE, BPF_REG_0, 0, 1),
|
||||||
BPF_EXIT_INSN(),
|
BPF_EXIT_INSN(),
|
||||||
BPF_JMP_IMM(BPF_JSGE, BPF_REG_0, 0, 1),
|
BPF_JMP_IMM(BPF_JSGE, BPF_REG_0, 0, 1),
|
||||||
BPF_EXIT_INSN(),
|
BPF_EXIT_INSN(),
|
||||||
BPF_ALU64_REG(BPF_SUB, BPF_REG_1, BPF_REG_0),
|
BPF_ALU64_REG(BPF_SUB, BPF_REG_6, BPF_REG_0),
|
||||||
BPF_EXIT_INSN(),
|
BPF_EXIT_INSN(),
|
||||||
},
|
},
|
||||||
.errstr_unpriv = "R1 tried to sub from different maps, paths, or prohibited types",
|
.errstr_unpriv = "R6 has pointer with unsupported alu operation",
|
||||||
.result_unpriv = REJECT,
|
.result_unpriv = REJECT,
|
||||||
.result = ACCEPT,
|
.result = ACCEPT,
|
||||||
},
|
},
|
||||||
@@ -61,7 +62,7 @@
|
|||||||
BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_1),
|
BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_1),
|
||||||
BPF_EXIT_INSN(),
|
BPF_EXIT_INSN(),
|
||||||
},
|
},
|
||||||
.errstr_unpriv = "R0 tried to sub from different maps, paths, or prohibited types",
|
.errstr_unpriv = "R1 has pointer with unsupported alu operation",
|
||||||
.errstr = "R0 tried to subtract pointer from scalar",
|
.errstr = "R0 tried to subtract pointer from scalar",
|
||||||
.result = REJECT,
|
.result = REJECT,
|
||||||
},
|
},
|
||||||
@@ -74,7 +75,7 @@
|
|||||||
BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_1),
|
BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_1),
|
||||||
BPF_EXIT_INSN(),
|
BPF_EXIT_INSN(),
|
||||||
},
|
},
|
||||||
.errstr_unpriv = "R0 tried to sub from different maps, paths, or prohibited types",
|
.errstr_unpriv = "R1 has pointer with unsupported alu operation",
|
||||||
.errstr = "R0 tried to subtract pointer from scalar",
|
.errstr = "R0 tried to subtract pointer from scalar",
|
||||||
.result = REJECT,
|
.result = REJECT,
|
||||||
},
|
},
|
||||||
@@ -88,7 +89,7 @@
|
|||||||
offsetof(struct __sk_buff, mark)),
|
offsetof(struct __sk_buff, mark)),
|
||||||
BPF_EXIT_INSN(),
|
BPF_EXIT_INSN(),
|
||||||
},
|
},
|
||||||
.errstr_unpriv = "R1 tried to sub from different maps, paths, or prohibited types",
|
.errstr_unpriv = "R1 has pointer with unsupported alu operation",
|
||||||
.errstr = "dereference of modified ctx ptr",
|
.errstr = "dereference of modified ctx ptr",
|
||||||
.result = REJECT,
|
.result = REJECT,
|
||||||
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
||||||
@@ -103,7 +104,7 @@
|
|||||||
offsetof(struct __sk_buff, mark)),
|
offsetof(struct __sk_buff, mark)),
|
||||||
BPF_EXIT_INSN(),
|
BPF_EXIT_INSN(),
|
||||||
},
|
},
|
||||||
.errstr_unpriv = "R1 tried to add from different maps, paths, or prohibited types",
|
.errstr_unpriv = "R1 has pointer with unsupported alu operation",
|
||||||
.errstr = "dereference of modified ctx ptr",
|
.errstr = "dereference of modified ctx ptr",
|
||||||
.result = REJECT,
|
.result = REJECT,
|
||||||
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
|
||||||
@@ -116,7 +117,7 @@
|
|||||||
BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_1),
|
BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_1),
|
||||||
BPF_EXIT_INSN(),
|
BPF_EXIT_INSN(),
|
||||||
},
|
},
|
||||||
.errstr_unpriv = "R0 tried to sub from different maps, paths, or prohibited types",
|
.errstr_unpriv = "R1 has pointer with unsupported alu operation",
|
||||||
.errstr = "R0 tried to subtract pointer from scalar",
|
.errstr = "R0 tried to subtract pointer from scalar",
|
||||||
.result = REJECT,
|
.result = REJECT,
|
||||||
},
|
},
|
||||||
|
@@ -19,7 +19,6 @@
|
|||||||
},
|
},
|
||||||
.fixup_map_hash_8b = { 3 },
|
.fixup_map_hash_8b = { 3 },
|
||||||
.errstr = "unbounded min value",
|
.errstr = "unbounded min value",
|
||||||
.errstr_unpriv = "R1 has unknown scalar with mixed signed bounds",
|
|
||||||
.result = REJECT,
|
.result = REJECT,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -43,7 +42,6 @@
|
|||||||
},
|
},
|
||||||
.fixup_map_hash_8b = { 3 },
|
.fixup_map_hash_8b = { 3 },
|
||||||
.errstr = "unbounded min value",
|
.errstr = "unbounded min value",
|
||||||
.errstr_unpriv = "R1 has unknown scalar with mixed signed bounds",
|
|
||||||
.result = REJECT,
|
.result = REJECT,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -69,7 +67,6 @@
|
|||||||
},
|
},
|
||||||
.fixup_map_hash_8b = { 3 },
|
.fixup_map_hash_8b = { 3 },
|
||||||
.errstr = "unbounded min value",
|
.errstr = "unbounded min value",
|
||||||
.errstr_unpriv = "R8 has unknown scalar with mixed signed bounds",
|
|
||||||
.result = REJECT,
|
.result = REJECT,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -94,7 +91,6 @@
|
|||||||
},
|
},
|
||||||
.fixup_map_hash_8b = { 3 },
|
.fixup_map_hash_8b = { 3 },
|
||||||
.errstr = "unbounded min value",
|
.errstr = "unbounded min value",
|
||||||
.errstr_unpriv = "R8 has unknown scalar with mixed signed bounds",
|
|
||||||
.result = REJECT,
|
.result = REJECT,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -141,7 +137,6 @@
|
|||||||
},
|
},
|
||||||
.fixup_map_hash_8b = { 3 },
|
.fixup_map_hash_8b = { 3 },
|
||||||
.errstr = "unbounded min value",
|
.errstr = "unbounded min value",
|
||||||
.errstr_unpriv = "R1 has unknown scalar with mixed signed bounds",
|
|
||||||
.result = REJECT,
|
.result = REJECT,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -210,7 +205,6 @@
|
|||||||
},
|
},
|
||||||
.fixup_map_hash_8b = { 3 },
|
.fixup_map_hash_8b = { 3 },
|
||||||
.errstr = "unbounded min value",
|
.errstr = "unbounded min value",
|
||||||
.errstr_unpriv = "R1 has unknown scalar with mixed signed bounds",
|
|
||||||
.result = REJECT,
|
.result = REJECT,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -260,7 +254,6 @@
|
|||||||
},
|
},
|
||||||
.fixup_map_hash_8b = { 3 },
|
.fixup_map_hash_8b = { 3 },
|
||||||
.errstr = "unbounded min value",
|
.errstr = "unbounded min value",
|
||||||
.errstr_unpriv = "R1 has unknown scalar with mixed signed bounds",
|
|
||||||
.result = REJECT,
|
.result = REJECT,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -287,7 +280,6 @@
|
|||||||
},
|
},
|
||||||
.fixup_map_hash_8b = { 3 },
|
.fixup_map_hash_8b = { 3 },
|
||||||
.errstr = "unbounded min value",
|
.errstr = "unbounded min value",
|
||||||
.errstr_unpriv = "R1 has unknown scalar with mixed signed bounds",
|
|
||||||
.result = REJECT,
|
.result = REJECT,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -313,7 +305,6 @@
|
|||||||
},
|
},
|
||||||
.fixup_map_hash_8b = { 3 },
|
.fixup_map_hash_8b = { 3 },
|
||||||
.errstr = "unbounded min value",
|
.errstr = "unbounded min value",
|
||||||
.errstr_unpriv = "R1 has unknown scalar with mixed signed bounds",
|
|
||||||
.result = REJECT,
|
.result = REJECT,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -342,7 +333,6 @@
|
|||||||
},
|
},
|
||||||
.fixup_map_hash_8b = { 3 },
|
.fixup_map_hash_8b = { 3 },
|
||||||
.errstr = "unbounded min value",
|
.errstr = "unbounded min value",
|
||||||
.errstr_unpriv = "R7 has unknown scalar with mixed signed bounds",
|
|
||||||
.result = REJECT,
|
.result = REJECT,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -372,7 +362,6 @@
|
|||||||
},
|
},
|
||||||
.fixup_map_hash_8b = { 4 },
|
.fixup_map_hash_8b = { 4 },
|
||||||
.errstr = "unbounded min value",
|
.errstr = "unbounded min value",
|
||||||
.errstr_unpriv = "R1 has unknown scalar with mixed signed bounds",
|
|
||||||
.result = REJECT,
|
.result = REJECT,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -400,7 +389,5 @@
|
|||||||
},
|
},
|
||||||
.fixup_map_hash_8b = { 3 },
|
.fixup_map_hash_8b = { 3 },
|
||||||
.errstr = "unbounded min value",
|
.errstr = "unbounded min value",
|
||||||
.errstr_unpriv = "R1 has unknown scalar with mixed signed bounds",
|
|
||||||
.result = REJECT,
|
.result = REJECT,
|
||||||
.result_unpriv = REJECT,
|
|
||||||
},
|
},
|
||||||
|
@@ -75,7 +75,7 @@
|
|||||||
},
|
},
|
||||||
.fixup_map_hash_16b = { 4 },
|
.fixup_map_hash_16b = { 4 },
|
||||||
.result_unpriv = REJECT,
|
.result_unpriv = REJECT,
|
||||||
.errstr_unpriv = "R1 tried to add from different maps, paths, or prohibited types",
|
.errstr_unpriv = "R1 has pointer with unsupported alu operation",
|
||||||
.result = ACCEPT,
|
.result = ACCEPT,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -93,6 +93,6 @@
|
|||||||
},
|
},
|
||||||
.fixup_map_hash_16b = { 4 },
|
.fixup_map_hash_16b = { 4 },
|
||||||
.result_unpriv = REJECT,
|
.result_unpriv = REJECT,
|
||||||
.errstr_unpriv = "R1 tried to add from different maps, paths, or prohibited types",
|
.errstr_unpriv = "R0 has pointer with unsupported alu operation",
|
||||||
.result = ACCEPT,
|
.result = ACCEPT,
|
||||||
},
|
},
|
||||||
|
@@ -504,7 +504,7 @@
|
|||||||
BPF_STX_MEM(BPF_DW, BPF_REG_1, BPF_REG_0, -8),
|
BPF_STX_MEM(BPF_DW, BPF_REG_1, BPF_REG_0, -8),
|
||||||
BPF_EXIT_INSN(),
|
BPF_EXIT_INSN(),
|
||||||
},
|
},
|
||||||
.errstr_unpriv = "R1 tried to add from different maps, paths, or prohibited types",
|
.errstr_unpriv = "R1 stack pointer arithmetic goes out of range",
|
||||||
.result_unpriv = REJECT,
|
.result_unpriv = REJECT,
|
||||||
.result = ACCEPT,
|
.result = ACCEPT,
|
||||||
},
|
},
|
||||||
|
@@ -21,8 +21,6 @@
|
|||||||
.fixup_map_hash_16b = { 5 },
|
.fixup_map_hash_16b = { 5 },
|
||||||
.fixup_map_array_48b = { 8 },
|
.fixup_map_array_48b = { 8 },
|
||||||
.result = ACCEPT,
|
.result = ACCEPT,
|
||||||
.result_unpriv = REJECT,
|
|
||||||
.errstr_unpriv = "R1 tried to add from different maps",
|
|
||||||
.retval = 1,
|
.retval = 1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -122,7 +120,7 @@
|
|||||||
.fixup_map_array_48b = { 1 },
|
.fixup_map_array_48b = { 1 },
|
||||||
.result = ACCEPT,
|
.result = ACCEPT,
|
||||||
.result_unpriv = REJECT,
|
.result_unpriv = REJECT,
|
||||||
.errstr_unpriv = "R2 tried to add from different pointers or scalars",
|
.errstr_unpriv = "R2 tried to add from different maps, paths or scalars",
|
||||||
.retval = 0,
|
.retval = 0,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -169,7 +167,7 @@
|
|||||||
.fixup_map_array_48b = { 1 },
|
.fixup_map_array_48b = { 1 },
|
||||||
.result = ACCEPT,
|
.result = ACCEPT,
|
||||||
.result_unpriv = REJECT,
|
.result_unpriv = REJECT,
|
||||||
.errstr_unpriv = "R2 tried to add from different maps, paths, or prohibited types",
|
.errstr_unpriv = "R2 tried to add from different maps, paths or scalars",
|
||||||
.retval = 0,
|
.retval = 0,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user