]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
bpf: fix up selftests after backports were fixed
authorOvidiu Panait <ovidiu.panait@windriver.com>
Fri, 28 May 2021 10:37:52 +0000 (13:37 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 3 Jun 2021 06:38:05 +0000 (08:38 +0200)
After the backport of the changes to fix CVE 2019-7308, the
selftests also need to be fixed up, as was done originally
in mainline 80c9b2fae87b ("bpf: add various test cases to selftests").

This is a backport of upstream commit 80c9b2fae87b ("bpf: add various test
cases to selftests") adapted to 4.19 in order to fix the
selftests that began to fail after CVE-2019-7308 fixes.

Suggested-by: Frank van der Linden <fllinden@amazon.com>
Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
tools/testing/selftests/bpf/test_verifier.c

index 9db5a7378f40fd6d1bce3938571688681d9a8022..fef1c9e3c4b815311d14e061e4bf405b8fc541d5 100644 (file)
@@ -2448,6 +2448,7 @@ static struct bpf_test tests[] = {
                },
                .result = REJECT,
                .errstr = "invalid stack off=-79992 size=8",
+               .errstr_unpriv = "R1 stack pointer arithmetic goes out of range",
        },
        {
                "PTR_TO_STACK store/load - out of bounds high",
@@ -2844,6 +2845,8 @@ static struct bpf_test tests[] = {
                        BPF_STX_MEM(BPF_DW, BPF_REG_1, BPF_REG_0, -8),
                        BPF_EXIT_INSN(),
                },
+               .errstr_unpriv = "R1 stack pointer arithmetic goes out of range",
+               .result_unpriv = REJECT,
                .result = ACCEPT,
        },
        {
@@ -7457,6 +7460,7 @@ static struct bpf_test tests[] = {
                },
                .fixup_map1 = { 3 },
                .errstr = "unbounded min value",
+               .errstr_unpriv = "R1 has unknown scalar with mixed signed bounds",
                .result = REJECT,
        },
        {
@@ -7481,6 +7485,7 @@ static struct bpf_test tests[] = {
                },
                .fixup_map1 = { 3 },
                .errstr = "unbounded min value",
+               .errstr_unpriv = "R1 has unknown scalar with mixed signed bounds",
                .result = REJECT,
        },
        {
@@ -7507,6 +7512,7 @@ static struct bpf_test tests[] = {
                },
                .fixup_map1 = { 3 },
                .errstr = "unbounded min value",
+               .errstr_unpriv = "R8 has unknown scalar with mixed signed bounds",
                .result = REJECT,
        },
        {
@@ -7532,6 +7538,7 @@ static struct bpf_test tests[] = {
                },
                .fixup_map1 = { 3 },
                .errstr = "unbounded min value",
+               .errstr_unpriv = "R8 has unknown scalar with mixed signed bounds",
                .result = REJECT,
        },
        {
@@ -7580,6 +7587,7 @@ static struct bpf_test tests[] = {
                },
                .fixup_map1 = { 3 },
                .errstr = "unbounded min value",
+               .errstr_unpriv = "R1 has unknown scalar with mixed signed bounds",
                .result = REJECT,
        },
        {
@@ -7651,6 +7659,7 @@ static struct bpf_test tests[] = {
                },
                .fixup_map1 = { 3 },
                .errstr = "unbounded min value",
+               .errstr_unpriv = "R1 has unknown scalar with mixed signed bounds",
                .result = REJECT,
        },
        {
@@ -7702,6 +7711,7 @@ static struct bpf_test tests[] = {
                },
                .fixup_map1 = { 3 },
                .errstr = "unbounded min value",
+               .errstr_unpriv = "R1 has unknown scalar with mixed signed bounds",
                .result = REJECT,
        },
        {
@@ -7729,6 +7739,7 @@ static struct bpf_test tests[] = {
                },
                .fixup_map1 = { 3 },
                .errstr = "unbounded min value",
+               .errstr_unpriv = "R1 has unknown scalar with mixed signed bounds",
                .result = REJECT,
        },
        {
@@ -7755,6 +7766,7 @@ static struct bpf_test tests[] = {
                },
                .fixup_map1 = { 3 },
                .errstr = "unbounded min value",
+               .errstr_unpriv = "R1 has unknown scalar with mixed signed bounds",
                .result = REJECT,
        },
        {
@@ -7784,6 +7796,7 @@ static struct bpf_test tests[] = {
                },
                .fixup_map1 = { 3 },
                .errstr = "unbounded min value",
+               .errstr_unpriv = "R7 has unknown scalar with mixed signed bounds",
                .result = REJECT,
        },
        {
@@ -7814,6 +7827,7 @@ static struct bpf_test tests[] = {
                },
                .fixup_map1 = { 4 },
                .errstr = "R0 invalid mem access 'inv'",
+               .errstr_unpriv = "R1 has unknown scalar with mixed signed bounds",
                .result = REJECT,
        },
        {
@@ -7842,6 +7856,7 @@ 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,
        },
@@ -7894,6 +7909,7 @@ static struct bpf_test tests[] = {
                },
                .fixup_map1 = { 3 },
                .errstr = "R0 min value is negative, either use unsigned index or do a if (index >=0) check.",
+               .errstr_unpriv = "R1 has unknown scalar with mixed signed bounds",
                .result = REJECT,
        },
        {
@@ -8266,6 +8282,7 @@ static struct bpf_test tests[] = {
                },
                .fixup_map1 = { 3 },
                .errstr = "pointer offset 1073741822",
+               .errstr_unpriv = "R0 pointer arithmetic of map value goes out of range",
                .result = REJECT
        },
        {
@@ -8287,6 +8304,7 @@ static struct bpf_test tests[] = {
                },
                .fixup_map1 = { 3 },
                .errstr = "pointer offset -1073741822",
+               .errstr_unpriv = "R0 pointer arithmetic of map value goes out of range",
                .result = REJECT
        },
        {
@@ -8458,6 +8476,7 @@ static struct bpf_test tests[] = {
                        BPF_EXIT_INSN()
                },
                .errstr = "fp pointer offset 1073741822",
+               .errstr_unpriv = "R1 stack pointer arithmetic goes out of range",
                .result = REJECT
        },
        {