]> git.baikalelectronics.ru Git - kernel.git/commit
selftests/bpf: Test passing rdonly mem to global func
authorKumar Kartikeya Dwivedi <memxor@gmail.com>
Sat, 19 Mar 2022 08:08:26 +0000 (13:38 +0530)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 6 Apr 2022 17:32:12 +0000 (10:32 -0700)
commit7bfb97460be9b25c83d5fbdc2c57d2bf3c4c9e3c
treeb26af2d3fe4d3faddbc6b6d917dd4bda2b25064e
parente492fd33e44e756fc8d029c171d9d0f191c0e505
selftests/bpf: Test passing rdonly mem to global func

Add two test cases, one pass read only map value pointer to global
func, which should be rejected. The same code checks it for kfunc, so
that is covered as well. Second one tries to use the missing check for
PTR_TO_MEM's MEM_RDONLY flag and tries to write to a read only memory
pointer. Without prior patches, both of these tests fail.

Reviewed-by: Hao Luo <haoluo@google.com>
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20220319080827.73251-5-memxor@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/prog_tests/ksyms_btf.c
tools/testing/selftests/bpf/prog_tests/test_global_funcs.c
tools/testing/selftests/bpf/progs/test_global_func17.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/test_ksyms_btf_write_check.c