mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-09 22:50:41 +00:00
selftests/bpf: Migrate expected_attach_type tests
Migrates tests from progs/test_sock_addr.c ensuring that programs fail to load when the expected attach type does not match. Signed-off-by: Jordan Rife <jrife@google.com> Link: https://lore.kernel.org/r/20240510190246.3247730-11-jrife@google.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
parent
8eaf8056a4
commit
b0f3af0bff
@ -490,6 +490,22 @@ static struct sock_addr_test tests[] = {
|
||||
NULL,
|
||||
SUCCESS,
|
||||
},
|
||||
{
|
||||
SOCK_ADDR_TEST_BIND,
|
||||
"bind4: load prog with wrong expected attach type",
|
||||
bind_v4_prog_load,
|
||||
bind_v4_prog_destroy,
|
||||
BPF_CGROUP_INET6_BIND,
|
||||
&user_ops,
|
||||
AF_INET,
|
||||
SOCK_STREAM,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
LOAD_REJECT,
|
||||
},
|
||||
{
|
||||
SOCK_ADDR_TEST_BIND,
|
||||
"bind6: bind (stream)",
|
||||
@ -522,6 +538,22 @@ static struct sock_addr_test tests[] = {
|
||||
NULL,
|
||||
SUCCESS,
|
||||
},
|
||||
{
|
||||
SOCK_ADDR_TEST_BIND,
|
||||
"bind6: load prog with wrong expected attach type",
|
||||
bind_v6_prog_load,
|
||||
bind_v6_prog_destroy,
|
||||
BPF_CGROUP_INET4_BIND,
|
||||
&user_ops,
|
||||
AF_INET6,
|
||||
SOCK_STREAM,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
LOAD_REJECT,
|
||||
},
|
||||
|
||||
/* bind - kernel calls */
|
||||
{
|
||||
@ -622,6 +654,22 @@ static struct sock_addr_test tests[] = {
|
||||
SRC4_REWRITE_IP,
|
||||
SUCCESS,
|
||||
},
|
||||
{
|
||||
SOCK_ADDR_TEST_CONNECT,
|
||||
"connect4: load prog with wrong expected attach type",
|
||||
connect_v4_prog_load,
|
||||
connect_v4_prog_destroy,
|
||||
BPF_CGROUP_INET6_CONNECT,
|
||||
&user_ops,
|
||||
AF_INET,
|
||||
SOCK_STREAM,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
LOAD_REJECT,
|
||||
},
|
||||
{
|
||||
SOCK_ADDR_TEST_CONNECT,
|
||||
"connect6: connect (stream)",
|
||||
@ -654,6 +702,22 @@ static struct sock_addr_test tests[] = {
|
||||
SRC6_REWRITE_IP,
|
||||
SUCCESS,
|
||||
},
|
||||
{
|
||||
SOCK_ADDR_TEST_CONNECT,
|
||||
"connect6: load prog with wrong expected attach type",
|
||||
connect_v6_prog_load,
|
||||
connect_v6_prog_destroy,
|
||||
BPF_CGROUP_INET4_CONNECT,
|
||||
&user_ops,
|
||||
AF_INET6,
|
||||
SOCK_STREAM,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
LOAD_REJECT,
|
||||
},
|
||||
{
|
||||
SOCK_ADDR_TEST_CONNECT,
|
||||
"connect_unix: connect (stream)",
|
||||
@ -786,6 +850,22 @@ static struct sock_addr_test tests[] = {
|
||||
SRC4_REWRITE_IP,
|
||||
SYSCALL_EPERM,
|
||||
},
|
||||
{
|
||||
SOCK_ADDR_TEST_SENDMSG,
|
||||
"sendmsg4: load prog with wrong expected attach type",
|
||||
sendmsg_v4_prog_load,
|
||||
sendmsg_v4_prog_destroy,
|
||||
BPF_CGROUP_UDP6_SENDMSG,
|
||||
&user_ops,
|
||||
AF_INET,
|
||||
SOCK_DGRAM,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
LOAD_REJECT,
|
||||
},
|
||||
{
|
||||
SOCK_ADDR_TEST_SENDMSG,
|
||||
"sendmsg6: sendmsg (dgram)",
|
||||
@ -866,6 +946,22 @@ static struct sock_addr_test tests[] = {
|
||||
SRC6_REWRITE_IP,
|
||||
SUCCESS,
|
||||
},
|
||||
{
|
||||
SOCK_ADDR_TEST_SENDMSG,
|
||||
"sendmsg6: load prog with wrong expected attach type",
|
||||
sendmsg_v6_prog_load,
|
||||
sendmsg_v6_prog_destroy,
|
||||
BPF_CGROUP_UDP4_SENDMSG,
|
||||
&user_ops,
|
||||
AF_INET6,
|
||||
SOCK_DGRAM,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
LOAD_REJECT,
|
||||
},
|
||||
{
|
||||
SOCK_ADDR_TEST_SENDMSG,
|
||||
"sendmsg_unix: sendmsg (dgram)",
|
||||
|
@ -97,20 +97,6 @@ static int sendmsg6_rw_asm_prog_load(const struct sock_addr_test *test);
|
||||
|
||||
static struct sock_addr_test tests[] = {
|
||||
/* bind */
|
||||
{
|
||||
"bind4: load prog with wrong expected attach type",
|
||||
bind4_prog_load,
|
||||
BPF_CGROUP_INET6_BIND,
|
||||
BPF_CGROUP_INET4_BIND,
|
||||
AF_INET,
|
||||
SOCK_STREAM,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
LOAD_REJECT,
|
||||
},
|
||||
{
|
||||
"bind4: attach prog with wrong attach type",
|
||||
bind4_prog_load,
|
||||
@ -125,20 +111,6 @@ static struct sock_addr_test tests[] = {
|
||||
NULL,
|
||||
ATTACH_REJECT,
|
||||
},
|
||||
{
|
||||
"bind6: load prog with wrong expected attach type",
|
||||
bind6_prog_load,
|
||||
BPF_CGROUP_INET4_BIND,
|
||||
BPF_CGROUP_INET6_BIND,
|
||||
AF_INET6,
|
||||
SOCK_STREAM,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
LOAD_REJECT,
|
||||
},
|
||||
{
|
||||
"bind6: attach prog with wrong attach type",
|
||||
bind6_prog_load,
|
||||
@ -155,20 +127,6 @@ static struct sock_addr_test tests[] = {
|
||||
},
|
||||
|
||||
/* connect */
|
||||
{
|
||||
"connect4: load prog with wrong expected attach type",
|
||||
connect4_prog_load,
|
||||
BPF_CGROUP_INET6_CONNECT,
|
||||
BPF_CGROUP_INET4_CONNECT,
|
||||
AF_INET,
|
||||
SOCK_STREAM,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
LOAD_REJECT,
|
||||
},
|
||||
{
|
||||
"connect4: attach prog with wrong attach type",
|
||||
connect4_prog_load,
|
||||
@ -183,20 +141,6 @@ static struct sock_addr_test tests[] = {
|
||||
NULL,
|
||||
ATTACH_REJECT,
|
||||
},
|
||||
{
|
||||
"connect6: load prog with wrong expected attach type",
|
||||
connect6_prog_load,
|
||||
BPF_CGROUP_INET4_CONNECT,
|
||||
BPF_CGROUP_INET6_CONNECT,
|
||||
AF_INET6,
|
||||
SOCK_STREAM,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
LOAD_REJECT,
|
||||
},
|
||||
{
|
||||
"connect6: attach prog with wrong attach type",
|
||||
connect6_prog_load,
|
||||
@ -213,20 +157,6 @@ static struct sock_addr_test tests[] = {
|
||||
},
|
||||
|
||||
/* sendmsg */
|
||||
{
|
||||
"sendmsg4: load prog with wrong expected attach type",
|
||||
sendmsg4_rw_asm_prog_load,
|
||||
BPF_CGROUP_UDP6_SENDMSG,
|
||||
BPF_CGROUP_UDP4_SENDMSG,
|
||||
AF_INET,
|
||||
SOCK_DGRAM,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
LOAD_REJECT,
|
||||
},
|
||||
{
|
||||
"sendmsg4: attach prog with wrong attach type",
|
||||
sendmsg4_rw_asm_prog_load,
|
||||
@ -255,20 +185,6 @@ static struct sock_addr_test tests[] = {
|
||||
SRC4_REWRITE_IP,
|
||||
SUCCESS,
|
||||
},
|
||||
{
|
||||
"sendmsg6: load prog with wrong expected attach type",
|
||||
sendmsg6_rw_asm_prog_load,
|
||||
BPF_CGROUP_UDP4_SENDMSG,
|
||||
BPF_CGROUP_UDP6_SENDMSG,
|
||||
AF_INET6,
|
||||
SOCK_DGRAM,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
LOAD_REJECT,
|
||||
},
|
||||
{
|
||||
"sendmsg6: attach prog with wrong attach type",
|
||||
sendmsg6_rw_asm_prog_load,
|
||||
|
Loading…
x
Reference in New Issue
Block a user