提交 d4e9835a 编写于 作者: L Lorenz Bauer 提交者: Zheng Zengkai

selftests: bpf: Don't run sk_lookup in verifier tests

stable inclusion
from stable-v5.10.135
commit 4bfc9dc60873923ffa64ee77084bac55031a30a0
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5ZWFM

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=4bfc9dc60873923ffa64ee77084bac55031a30a0

--------------------------------

commit b4f89463 upstream.

sk_lookup doesn't allow setting data_in for bpf_prog_run. This doesn't
play well with the verifier tests, since they always set a 64 byte
input buffer. Allow not running verifier tests by setting
bpf_test.runs to a negative value and don't run the ctx access case
for sk_lookup. We have dedicated ctx access tests so skipping here
doesn't reduce coverage.
Signed-off-by: NLorenz Bauer <lmb@cloudflare.com>
Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20210303101816.36774-6-lmb@cloudflare.comSigned-off-by: NTianchen Ding <dtcccc@linux.alibaba.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NPu Lehui <pulehui@huawei.com>
Reviewed-by: NKuohai Xu <xukuohai@huawei.com>
Reviewed-by: NKuohai Xu <xukuohai@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 f4f55c33
...@@ -101,7 +101,7 @@ struct bpf_test { ...@@ -101,7 +101,7 @@ struct bpf_test {
enum bpf_prog_type prog_type; enum bpf_prog_type prog_type;
uint8_t flags; uint8_t flags;
void (*fill_helper)(struct bpf_test *self); void (*fill_helper)(struct bpf_test *self);
uint8_t runs; int runs;
#define bpf_testdata_struct_t \ #define bpf_testdata_struct_t \
struct { \ struct { \
uint32_t retval, retval_unpriv; \ uint32_t retval, retval_unpriv; \
...@@ -1064,7 +1064,7 @@ static void do_test_single(struct bpf_test *test, bool unpriv, ...@@ -1064,7 +1064,7 @@ static void do_test_single(struct bpf_test *test, bool unpriv,
run_errs = 0; run_errs = 0;
run_successes = 0; run_successes = 0;
if (!alignment_prevented_execution && fd_prog >= 0) { if (!alignment_prevented_execution && fd_prog >= 0 && test->runs >= 0) {
uint32_t expected_val; uint32_t expected_val;
int i; int i;
......
...@@ -239,6 +239,7 @@ ...@@ -239,6 +239,7 @@
.result = ACCEPT, .result = ACCEPT,
.prog_type = BPF_PROG_TYPE_SK_LOOKUP, .prog_type = BPF_PROG_TYPE_SK_LOOKUP,
.expected_attach_type = BPF_SK_LOOKUP, .expected_attach_type = BPF_SK_LOOKUP,
.runs = -1,
}, },
/* invalid 8-byte reads from a 4-byte fields in bpf_sk_lookup */ /* invalid 8-byte reads from a 4-byte fields in bpf_sk_lookup */
{ {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册