From: Tiezhu Yang <yangtiezhu@loongson.cn>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Sasha Levin <sashal@kernel.org>
Cc: stable@vger.kernel.org, bpf@vger.kernel.org,
Daniel Borkmann <daniel@iogearbox.net>,
Alexei Starovoitov <ast@kernel.org>
Subject: [PATCH 4.19 1/9] bpf: fix test suite to enable all unpriv program types
Date: Wed, 2 Jun 2021 11:27:45 +0800 [thread overview]
Message-ID: <1622604473-781-2-git-send-email-yangtiezhu@loongson.cn> (raw)
In-Reply-To: <1622604473-781-1-git-send-email-yangtiezhu@loongson.cn>
From: Daniel Borkmann <daniel@iogearbox.net>
commit 36641ad61db5ce9befd5eb0071abb36eaff16cfc upstream
Given BPF_PROG_TYPE_CGROUP_SKB program types are also valid in an
unprivileged setting, lets not omit these tests and potentially
have issues fall through the cracks. Make this more obvious by
adding a small test_as_unpriv() helper.
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
tools/testing/selftests/bpf/test_verifier.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
index e1e4b6a..d33d1d7 100644
--- a/tools/testing/selftests/bpf/test_verifier.c
+++ b/tools/testing/selftests/bpf/test_verifier.c
@@ -4798,6 +4798,7 @@ static struct bpf_test tests[] = {
.fixup_cgroup_storage = { 1 },
.result = REJECT,
.errstr = "get_local_storage() doesn't support non-zero flags",
+ .errstr_unpriv = "R2 leaks addr into helper function",
.prog_type = BPF_PROG_TYPE_CGROUP_SKB,
},
{
@@ -12963,6 +12964,13 @@ static void get_unpriv_disabled()
fclose(fd);
}
+static bool test_as_unpriv(struct bpf_test *test)
+{
+ return !test->prog_type ||
+ test->prog_type == BPF_PROG_TYPE_SOCKET_FILTER ||
+ test->prog_type == BPF_PROG_TYPE_CGROUP_SKB;
+}
+
static int do_test(bool unpriv, unsigned int from, unsigned int to)
{
int i, passes = 0, errors = 0, skips = 0;
@@ -12973,10 +12981,10 @@ static int do_test(bool unpriv, unsigned int from, unsigned int to)
/* Program types that are not supported by non-root we
* skip right away.
*/
- if (!test->prog_type && unpriv_disabled) {
+ if (test_as_unpriv(test) && unpriv_disabled) {
printf("#%d/u %s SKIP\n", i, test->descr);
skips++;
- } else if (!test->prog_type) {
+ } else if (test_as_unpriv(test)) {
if (!unpriv)
set_admin(false);
printf("#%d/u %s ", i, test->descr);
--
2.1.0
next prev parent reply other threads:[~2021-06-02 3:28 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-02 3:27 [PATCH 4.19 0/9] bpf: fix verifier selftests on inefficient unaligned access architectures Tiezhu Yang
2021-06-02 3:27 ` Tiezhu Yang [this message]
2021-06-02 3:27 ` [PATCH 4.19 2/9] bpf: test make sure to run unpriv test cases in test_verifier Tiezhu Yang
2021-06-02 3:27 ` [PATCH 4.19 3/9] selftests/bpf: Generalize dummy program types Tiezhu Yang
2021-06-02 3:27 ` [PATCH 4.19 4/9] bpf: Add BPF_F_ANY_ALIGNMENT Tiezhu Yang
2021-06-02 3:27 ` [PATCH 4.19 5/9] bpf: Adjust F_NEEDS_EFFICIENT_UNALIGNED_ACCESS handling in test_verifier.c Tiezhu Yang
2021-06-02 3:27 ` [PATCH 4.19 6/9] bpf: Make more use of 'any' alignment " Tiezhu Yang
2021-06-02 3:27 ` [PATCH 4.19 7/9] bpf: Apply F_NEEDS_EFFICIENT_UNALIGNED_ACCESS to more ACCEPT test cases Tiezhu Yang
2021-06-02 3:27 ` [PATCH 4.19 8/9] selftests/bpf: add "any alignment" annotation for some tests Tiezhu Yang
2021-06-02 3:27 ` [PATCH 4.19 9/9] selftests/bpf: Avoid running unprivileged tests with alignment requirements Tiezhu Yang
2021-06-05 7:16 ` [PATCH 4.19 0/9] bpf: fix verifier selftests on inefficient unaligned access architectures Tiezhu Yang
2021-06-08 14:40 ` Greg Kroah-Hartman
2021-06-08 14:45 ` Greg Kroah-Hartman
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=1622604473-781-2-git-send-email-yangtiezhu@loongson.cn \
--to=yangtiezhu@loongson.cn \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=gregkh@linuxfoundation.org \
--cc=sashal@kernel.org \
--cc=stable@vger.kernel.org \
/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).