diff options
author | Roberto Sassu <roberto.sassu@huawei.com> | 2022-10-06 13:07:36 +0200 |
---|---|---|
committer | Andrii Nakryiko <andrii@kernel.org> | 2022-10-10 16:49:43 -0700 |
commit | a9c7c18b57594c72a63fad749021b743c65a098b (patch) | |
tree | ac20de3e8053e3d82b65622bfe106d4243101fe4 /tools/testing/selftests/bpf/prog_tests/bpf_iter.c | |
parent | 97c8f9dd5db839f2387785ee936d0a5b257b31d3 (diff) |
selftests/bpf: Add tests for _opts variants of bpf_*_get_fd_by_id()
Introduce the data_input map, write-protected with a small eBPF program
implementing the lsm/bpf_map hook.
Then, ensure that bpf_map_get_fd_by_id() and bpf_map_get_fd_by_id_opts()
with NULL opts don't succeed due to requesting read-write access to the
write-protected map. Also, ensure that bpf_map_get_fd_by_id_opts() with
open_flags in opts set to BPF_F_RDONLY instead succeeds.
After obtaining a read-only fd, ensure that only map lookup succeeds and
not update. Ensure that update works only with the read-write fd obtained
at program loading time, when the write protection was not yet enabled.
Finally, ensure that the other _opts variants of bpf_*_get_fd_by_id() don't
work if the BPF_F_RDONLY flag is set in opts (due to the kernel not
handling the open_flags member of bpf_attr).
Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20221006110736.84253-7-roberto.sassu@huaweicloud.com
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/bpf_iter.c')
0 files changed, 0 insertions, 0 deletions