Skip to content

Commit 9ec8a4c

Browse files
fomichevAlexei Starovoitov
authored andcommitted
selftests/bpf: add sockopt test
Add sockopt selftests: * require proper expected_attach_type * enforce context field read/write access * test bpf_sockopt_handled handler * test EPERM * test limiting optlen from getsockopt * test out-of-bounds access v9: * add tests for setsockopt argument mangling v7: * remove return 2; test retval=0 and optlen=-1 v3: * use DW for optval{,_end} loads v2: * use return code 2 for kernel bypass Cc: Andrii Nakryiko <andriin@fb.com> Cc: Martin Lau <kafai@fb.com> Signed-off-by: Stanislav Fomichev <sdf@google.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent 47ac90b commit 9ec8a4c

File tree

3 files changed

+1024
-1
lines changed

3 files changed

+1024
-1
lines changed

tools/testing/selftests/bpf/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,4 @@ libbpf.so.*
3939
test_hashmap
4040
test_btf_dump
4141
xdping
42+
test_sockopt

tools/testing/selftests/bpf/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test
2626
test_sock test_btf test_sockmap get_cgroup_id_user test_socket_cookie \
2727
test_cgroup_storage test_select_reuseport test_section_names \
2828
test_netcnt test_tcpnotify_user test_sock_fields test_sysctl test_hashmap \
29-
test_btf_dump test_cgroup_attach xdping
29+
test_btf_dump test_cgroup_attach xdping test_sockopt
3030

3131
BPF_OBJ_FILES = $(patsubst %.c,%.o, $(notdir $(wildcard progs/*.c)))
3232
TEST_GEN_FILES = $(BPF_OBJ_FILES)
@@ -103,6 +103,7 @@ $(OUTPUT)/test_netcnt: cgroup_helpers.c
103103
$(OUTPUT)/test_sock_fields: cgroup_helpers.c
104104
$(OUTPUT)/test_sysctl: cgroup_helpers.c
105105
$(OUTPUT)/test_cgroup_attach: cgroup_helpers.c
106+
$(OUTPUT)/test_sockopt: cgroup_helpers.c
106107

107108
.PHONY: force
108109

0 commit comments

Comments
 (0)