提交 678437b9 编写于 作者: D Daniel Borkmann 提交者: Yang Yingliang

bpf: fix test suite to enable all unpriv program types

commit 36641ad6 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: NDaniel Borkmann <daniel@iogearbox.net>
Acked-by: NAlexei Starovoitov <ast@kernel.org>
Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
Signed-off-by: NTiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 a097632a
...@@ -4798,6 +4798,7 @@ static struct bpf_test tests[] = { ...@@ -4798,6 +4798,7 @@ static struct bpf_test tests[] = {
.fixup_cgroup_storage = { 1 }, .fixup_cgroup_storage = { 1 },
.result = REJECT, .result = REJECT,
.errstr = "get_local_storage() doesn't support non-zero flags", .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, .prog_type = BPF_PROG_TYPE_CGROUP_SKB,
}, },
{ {
...@@ -12963,6 +12964,13 @@ static void get_unpriv_disabled() ...@@ -12963,6 +12964,13 @@ static void get_unpriv_disabled()
fclose(fd); 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) static int do_test(bool unpriv, unsigned int from, unsigned int to)
{ {
int i, passes = 0, errors = 0, skips = 0; int i, passes = 0, errors = 0, skips = 0;
...@@ -12973,10 +12981,10 @@ static int do_test(bool unpriv, unsigned int from, unsigned int to) ...@@ -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 /* Program types that are not supported by non-root we
* skip right away. * 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); printf("#%d/u %s SKIP\n", i, test->descr);
skips++; skips++;
} else if (!test->prog_type) { } else if (test_as_unpriv(test)) {
if (!unpriv) if (!unpriv)
set_admin(false); set_admin(false);
printf("#%d/u %s ", i, test->descr); printf("#%d/u %s ", i, test->descr);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册