From 1644bbec6161ec971a2ba3c213ce285b995cac22 Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Thu, 1 Jun 2023 11:04:38 +0200 Subject: cooker: OP_CALL and OP_COPY stuff ...mostly. Signed-off-by: Stefano Brivio --- cooker/calls/fs.c | 38 +++++++++------ cooker/calls/ioctl.c | 72 +++++++++++++++++----------- cooker/calls/net.c | 124 +++++++++++++++++++++++++++++++++++-------------- cooker/calls/process.c | 12 +++-- 4 files changed, 166 insertions(+), 80 deletions(-) (limited to 'cooker/calls') diff --git a/cooker/calls/fs.c b/cooker/calls/fs.c index d800f38..924907d 100644 --- a/cooker/calls/fs.c +++ b/cooker/calls/fs.c @@ -66,23 +66,35 @@ swapoff #include "../calls.h" static struct arg mknod_args[] = { - { - 0, "path", STRING, 1 /* TODO: PATH_MAX */, - { 0 } + { 0, + { + "path", STRING, 0, + 0, 1 /* TODO: PATH_MAX */, + { 0 } + } }, - { - 1, "mode", INTFLAGS, 0, - { 0 /* TODO */ }, + { 1, + { + "mode", UNDEF /* TODO */, FLAGS, + 0, 0, + { 0 /* TODO */ }, + } }, - { - 2, "major", UNDEF /* TODO */, 0, - { 0 }, + { 2, + { + "major", UNDEF /* TODO */, 0, + 0, 0, + { 0 }, + } }, - { - 2, "minor", UNDEF /* TODO */, 0, - { 0 }, + { 2, + { + "minor", UNDEF /* TODO */, 0, + 0, 0, + { 0 }, + } }, - { 0 }, + { 0 } }; struct call syscalls_fs[] = { diff --git a/cooker/calls/ioctl.c b/cooker/calls/ioctl.c index 576e02e..a60b834 100644 --- a/cooker/calls/ioctl.c +++ b/cooker/calls/ioctl.c @@ -71,38 +71,50 @@ static struct num tun_ifr_flags[] = { static struct field tun_ifr[] = { /* netdevice(7) */ { - "name", STRING, + "name", STRING, 0, offsetof(struct ifreq, ifr_name), IFNAMSIZ, { 0 }, }, { - "flags", INT, /* One allowed at a time? */ + "flags", INT, /* One allowed at a time? */ 0, offsetof(struct ifreq, ifr_flags), 0, { .d_num = tun_ifr_flags }, }, }; static struct select_num ioctl_request_arg[] = { - { - FS_IOC_GETFLAGS, - { 2, "argp", INTFLAGS, sizeof(int), { .d_num = attr } } + { FS_IOC_GETFLAGS, + { 2, + { + "argp", INT, FLAGS, + sizeof(int), 0, + { .d_num = attr } + } + } }, - { - FS_IOC_SETFLAGS, - { 2, "argp", INTFLAGS, sizeof(int), { .d_num = attr } } + { FS_IOC_SETFLAGS, + { 2, + { + "argp", INT, FLAGS, + sizeof(int), 0, + { .d_num = attr } + } + } }, - { - TUNSETIFF, - { - 2, "ifr", STRUCT, sizeof(struct ifreq), - { .d_struct = tun_ifr } + { TUNSETIFF, + { 2, + { + "ifr", STRUCT, 0, + sizeof(struct ifreq), 0, + { .d_struct = tun_ifr } + } } }, { 0 }, }; static struct field ioctl_request = { - "request", INT, 0, 0, { .d_num = request }, + "request", INT, 0, 0, 0, { .d_num = request }, }; static struct select ioctl_request_select = { @@ -110,21 +122,29 @@ static struct select ioctl_request_select = { }; static struct arg ioctl_args[] = { - { - 0, "path", FDPATH, 0, - { 0 } + { 0, + { + "path", FDPATH, 0, 0, 0, + { 0 } + } }, - { - 0, "fd", INT, 0, - { 0 } + { 0, + { + "fd", INT, 0, 0, 0, + { 0 } + } }, - { - 1, "request", SELECT, 0, - { .d_select = &ioctl_request_select } + { 1, + { + "request", SELECT, 0, 0, 0, + { .d_select = &ioctl_request_select } + } }, - { - 2, "arg", SELECTED, -1, - { 0 } + { 2, + { + "arg", SELECTED, 0, -1, 0, + { 0 } + } }, { 0 }, }; diff --git a/cooker/calls/net.c b/cooker/calls/net.c index df97aab..f5e2728 100644 --- a/cooker/calls/net.c +++ b/cooker/calls/net.c @@ -83,16 +83,36 @@ static struct num protocols[] = { }; static struct arg socket_args[] = { - { 0, "family", INT, 0, { .d_num = af } }, - { 1, "type", INTMASK, 0, { .d_num = socket_types } }, - { 1, "flags", INTFLAGS, 0, { .d_num = socket_flags } }, - { 2, "protocol", INT, 0, { .d_num = protocols } }, + { 0, + { + "family", INT, 0, 0, 0, + { .d_num = af } + } + }, + { 1, + { + "type", INT, MASK, 0, 0, + { .d_num = socket_types } + } + }, + { 1, + { + "flags", INT, FLAGS, 0, 0, + { .d_num = socket_flags } + } + }, + { 2, + { + "protocol", INT, 0, 0, 0, + { .d_num = protocols } + } + }, { 0 }, }; static struct field connect_addr_unix[] = { { - "path", STRING, + "path", STRING, 0, offsetof(struct sockaddr_un, sun_path), UNIX_PATH_MAX, { 0 } }, @@ -101,12 +121,12 @@ static struct field connect_addr_unix[] = { static struct field connect_addr_ipv4[] = { { - "port", PORT, + "port", PORT, 0, offsetof(struct sockaddr_in, sin_port), 0, { 0 } }, { - "addr", IPV4, + "addr", IPV4, 0, offsetof(struct sockaddr_in, sin_addr), 0, { 0 } }, @@ -115,12 +135,12 @@ static struct field connect_addr_ipv4[] = { static struct field connect_addr_ipv6[] = { { - "port", PORT, + "port", PORT, 0, offsetof(struct sockaddr_in6, sin6_port), 0, { 0 } }, { - "addr", IPV6, + "addr", IPV6, 0, offsetof(struct sockaddr_in6, sin6_addr), 0, { 0 } }, @@ -129,12 +149,12 @@ static struct field connect_addr_ipv6[] = { static struct field connect_addr_nl[] = { { - "pid", PID, + "pid", PID, 0, offsetof(struct sockaddr_nl, nl_pid), 0, { 0 } }, { - "groups", U32, + "groups", U32, 0, offsetof(struct sockaddr_nl, nl_groups), 0, { 0 } }, @@ -142,27 +162,43 @@ static struct field connect_addr_nl[] = { }; static struct field connect_family = { - "family", INT, + "family", INT, 0, offsetof(struct sockaddr, sa_family), 0, { .d_num = af } }; static struct select_num connect_addr_select_family[] = { - { - AF_UNIX, - { 1, NULL, STRUCT, 0, { .d_struct = connect_addr_unix } } + { AF_UNIX, + { 1, + { + NULL, STRUCT, 0, 0, 0, + { .d_struct = connect_addr_unix } + } + } }, - { - AF_INET, - { 1, NULL, STRUCT, 0, { .d_struct = connect_addr_ipv4 } } + { AF_INET, + { 1, + { + NULL, STRUCT, 0, 0, 0, + { .d_struct = connect_addr_ipv4 } + } + } }, - { - AF_INET6, - { 1, NULL, STRUCT, 0, { .d_struct = connect_addr_ipv6 } } + { AF_INET6, + { 1, + { + NULL, STRUCT, 0, 0, 0, + { .d_struct = connect_addr_ipv6 } + } + } }, - { - AF_NETLINK, - { 1, NULL, STRUCT, 0, { .d_struct = connect_addr_nl } } + { AF_NETLINK, + { 1, + { + NULL, STRUCT, 0, 0, 0, + { .d_struct = connect_addr_nl } + } + } }, { 0 }, }; @@ -172,21 +208,37 @@ static struct select connect_addr_select = { }; static struct arg connect_args[] = { - { - 0, "fd", INT, 0, - { 0 }, + { 0, + { + "fd", INT, 0, + 0, + 0, + { 0 }, + }, }, - { - 0, "path", FDPATH, 0, - { 0 }, + { 0, + { + "path", FDPATH, 0, + 0, + 0, + { 0 }, + }, }, - { - 1, "addr", SELECT, sizeof(struct sockaddr_storage), - { .d_select = &connect_addr_select }, + { 1, + { + "addr", SELECT, 0, + 0, + sizeof(struct sockaddr_storage), + { .d_select = &connect_addr_select }, + }, }, - { - 2, "addrlen", LONG, 0, - { 0 }, + { 2, + { + "addrlen", LONG, SIZE, + 0, + 0, + { .d_arg_size = 1 }, + }, }, }; diff --git a/cooker/calls/process.c b/cooker/calls/process.c index 7c0f36e..b133629 100644 --- a/cooker/calls/process.c +++ b/cooker/calls/process.c @@ -36,13 +36,15 @@ clone3 #include "../calls.h" static struct arg unshare_args[] = { - { - 0, "flags", INTFLAGS, 0, - { 0 /* TODO */ } - }, + { 0, + { + "flags", UNDEF /* TODO */, FLAGS, 0, 0, + { 0 /* TODO */ } + } + } }; struct call syscalls_process[] = { { __NR_unshare, "unshare", unshare_args }, - { 0 }, + { 0 } }; -- cgit v1.2.3