selftests/bpf: Add a test for out of bound rdonly buf access
authorYonghong Song <yhs@fb.com>
Thu, 23 Jul 2020 18:41:24 +0000 (11:41 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Sun, 26 Jul 2020 03:16:34 +0000 (20:16 -0700)
commit9efcc4ad7a15ea50550c53fbf62457c309216051
treead893338be4daaf48000287dc6eb57a00e76ff8c
parent3b1c420bd882115eb7a3d2335cc00d7b9974eb0b
selftests/bpf: Add a test for out of bound rdonly buf access

If the bpf program contains out of bound access w.r.t. a
particular map key/value size, the verification will be
still okay, e.g., it will be accepted by verifier. But
it will be rejected during link_create time. A test
is added here to ensure link_create failure did happen
if out of bound access happened.
  $ ./test_progs -n 4
  ...
  #4/23 rdonly-buf-out-of-bound:OK
  ...

Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200723184124.591700-1-yhs@fb.com
tools/testing/selftests/bpf/prog_tests/bpf_iter.c
tools/testing/selftests/bpf/progs/bpf_iter_test_kern5.c [new file with mode: 0644]