From: Frank van der Linden <fllinden@amazon.com>
To: <stable@vger.kernel.org>
Cc: <bpf@vger.kernel.org>, <ast@kernel.org>, <daniel@iogearbox.net>,
<yhs@fb.com>, <john.fastabend@gmail.com>, <samjonas@amazon.com>
Subject: [PATCH 4.14 11/15] bpf: Update selftests to reflect new error states
Date: Sat, 1 May 2021 04:30:10 +0000 [thread overview]
Message-ID: <20210501043014.33300-12-fllinden@amazon.com> (raw)
In-Reply-To: <20210501043014.33300-1-fllinden@amazon.com>
From: Daniel Borkmann <daniel@iogearbox.net>
Upstream commit d7a5091351756d0ae8e63134313c455624e36a13
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>
[fllinden@amazon.com - 4.14 backport, account for split test_verifier and
different / missing tests]
Signed-off-by: Frank van der Linden <fllinden@amazon.com>
---
tools/testing/selftests/bpf/test_verifier.c | 34 ++++++++-------------
1 file changed, 12 insertions(+), 22 deletions(-)
diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
index 43d91b2d2a21..bab9942b20b2 100644
--- a/tools/testing/selftests/bpf/test_verifier.c
+++ b/tools/testing/selftests/bpf/test_verifier.c
@@ -2243,7 +2243,7 @@ static struct bpf_test tests[] = {
BPF_STX_MEM(BPF_DW, BPF_REG_1, BPF_REG_0, -8),
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 = ACCEPT,
},
@@ -6220,7 +6220,6 @@ static struct bpf_test tests[] = {
},
.fixup_map1 = { 3 },
.errstr = "unbounded min value",
- .errstr_unpriv = "R1 has unknown scalar with mixed signed bounds",
.result = REJECT,
},
{
@@ -6245,7 +6244,6 @@ static struct bpf_test tests[] = {
},
.fixup_map1 = { 3 },
.errstr = "unbounded min value",
- .errstr_unpriv = "R1 has unknown scalar with mixed signed bounds",
.result = REJECT,
},
{
@@ -6272,7 +6270,6 @@ static struct bpf_test tests[] = {
},
.fixup_map1 = { 3 },
.errstr = "unbounded min value",
- .errstr_unpriv = "R8 has unknown scalar with mixed signed bounds",
.result = REJECT,
},
{
@@ -6298,7 +6295,6 @@ static struct bpf_test tests[] = {
},
.fixup_map1 = { 3 },
.errstr = "unbounded min value",
- .errstr_unpriv = "R8 has unknown scalar with mixed signed bounds",
.result = REJECT,
},
{
@@ -6347,7 +6343,6 @@ static struct bpf_test tests[] = {
},
.fixup_map1 = { 3 },
.errstr = "unbounded min value",
- .errstr_unpriv = "R1 has unknown scalar with mixed signed bounds",
.result = REJECT,
},
{
@@ -6419,7 +6414,6 @@ static struct bpf_test tests[] = {
},
.fixup_map1 = { 3 },
.errstr = "unbounded min value",
- .errstr_unpriv = "R1 has unknown scalar with mixed signed bounds",
.result = REJECT,
},
{
@@ -6471,7 +6465,6 @@ static struct bpf_test tests[] = {
},
.fixup_map1 = { 3 },
.errstr = "unbounded min value",
- .errstr_unpriv = "R1 has unknown scalar with mixed signed bounds",
.result = REJECT,
},
{
@@ -6499,7 +6492,6 @@ static struct bpf_test tests[] = {
},
.fixup_map1 = { 3 },
.errstr = "unbounded min value",
- .errstr_unpriv = "R1 has unknown scalar with mixed signed bounds",
.result = REJECT,
},
{
@@ -6526,7 +6518,6 @@ static struct bpf_test tests[] = {
},
.fixup_map1 = { 3 },
.errstr = "unbounded min value",
- .errstr_unpriv = "R1 has unknown scalar with mixed signed bounds",
.result = REJECT,
},
{
@@ -6556,7 +6547,6 @@ static struct bpf_test tests[] = {
},
.fixup_map1 = { 3 },
.errstr = "unbounded min value",
- .errstr_unpriv = "R7 has unknown scalar with mixed signed bounds",
.result = REJECT,
},
{
@@ -6615,7 +6605,6 @@ static struct bpf_test tests[] = {
},
.fixup_map1 = { 3 },
.errstr = "unbounded min value",
- .errstr_unpriv = "R1 has unknown scalar with mixed signed bounds",
.result = REJECT,
.result_unpriv = REJECT,
},
@@ -7779,7 +7768,7 @@ static struct bpf_test tests[] = {
BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_1),
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",
.result = REJECT,
},
@@ -7794,7 +7783,7 @@ static struct bpf_test tests[] = {
BPF_ALU64_REG(BPF_SUB, BPF_REG_1, BPF_REG_0),
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 = ACCEPT,
},
@@ -7806,22 +7795,23 @@ static struct bpf_test tests[] = {
BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_1),
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",
.result = REJECT,
},
{
"check deducing bounds from const, 4",
.insns = {
+ BPF_MOV64_REG(BPF_REG_6, BPF_REG_1),
BPF_MOV64_IMM(BPF_REG_0, 0),
BPF_JMP_IMM(BPF_JSLE, BPF_REG_0, 0, 1),
BPF_EXIT_INSN(),
BPF_JMP_IMM(BPF_JSGE, BPF_REG_0, 0, 1),
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(),
},
- .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 = ACCEPT,
},
@@ -7833,7 +7823,7 @@ static struct bpf_test tests[] = {
BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_1),
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",
.result = REJECT,
},
@@ -7846,7 +7836,7 @@ static struct bpf_test tests[] = {
BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_1),
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",
.result = REJECT,
},
@@ -7860,7 +7850,7 @@ static struct bpf_test tests[] = {
offsetof(struct __sk_buff, mark)),
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",
.result = REJECT,
},
@@ -7874,7 +7864,7 @@ static struct bpf_test tests[] = {
offsetof(struct __sk_buff, mark)),
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",
.result = REJECT,
},
@@ -7886,7 +7876,7 @@ static struct bpf_test tests[] = {
BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_1),
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",
.result = REJECT,
},
--
2.23.3
next prev parent reply other threads:[~2021-05-01 4:30 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-01 4:29 [PATCH 4.14 00/15] fix backports, add CVE-2021-29155 fixes Frank van der Linden
2021-05-01 4:30 ` [PATCH 4.14 01/15] bpf: Fix backport of "bpf: restrict unknown scalars of mixed signed bounds for unprivileged" Frank van der Linden
2021-05-01 4:30 ` [PATCH 4.14 02/15] bpf: fix up selftests after backports were fixed Frank van der Linden
2021-05-01 4:30 ` [PATCH 4.14 03/15] bpf, selftests: Fix up some test_verifier cases for unprivileged Frank van der Linden
2021-05-01 4:30 ` [PATCH 4.14 04/15] bpf: Move off_reg into sanitize_ptr_alu Frank van der Linden
2021-05-01 4:30 ` [PATCH 4.14 05/15] bpf: Ensure off_reg has no mixed signed bounds for all types Frank van der Linden
2021-05-01 4:30 ` [PATCH 4.14 06/15] bpf: Rework ptr_limit into alu_limit and add common error path Frank van der Linden
2021-05-01 4:30 ` [PATCH 4.14 07/15] bpf: Improve verifier error messages for users Frank van der Linden
2021-05-01 4:30 ` [PATCH 4.14 08/15] bpf: Refactor and streamline bounds check into helper Frank van der Linden
2021-05-01 4:30 ` [PATCH 4.14 09/15] bpf: Move sanitize_val_alu out of op switch Frank van der Linden
2021-05-01 4:30 ` [PATCH 4.14 10/15] bpf: Tighten speculative pointer arithmetic mask Frank van der Linden
2021-05-01 4:30 ` Frank van der Linden [this message]
2021-05-01 4:30 ` [PATCH 4.14 12/15] bpf: do not allow root to mangle valid pointers Frank van der Linden
2021-05-01 4:30 ` [PATCH 4.14 13/15] bpf/verifier: disallow pointer subtraction Frank van der Linden
2021-05-01 4:30 ` [PATCH 4.14 14/15] selftests/bpf: fix test_align Frank van der Linden
2021-05-01 4:30 ` [PATCH 4.14 15/15] selftests/bpf: make 'dubious pointer arithmetic' test useful Frank van der Linden
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210501043014.33300-12-fllinden@amazon.com \
--to=fllinden@amazon.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=samjonas@amazon.com \
--cc=stable@vger.kernel.org \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).