linux-user: Support the accept4 socketcall
PATCH v2 1/1 linux-user: Support the accept4 socketcall
From: André Hentschel <[email protected]>
---
See https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/net.h for the value.
linux-user/syscall.c | 16 ++++++++++++++++ linux-user/syscall_defs.h | 1 + 2 files changed, 17 insertions(+)
linux-user/syscall.c +16 -0
@@ -2245,6 +2245,22 @@ static abi_long do_socketcall(int num, abi_ulong vptr) ret =do_accept4 (sockfd, target_addr, target_addrlen,0 ); }break ; +case SOCKOP_accept4: + { +abi_ulong sockfd; +abi_ulong target_addr, target_addrlen; +int flags; + +if (get_user_ual (sockfd, vptr) + ||get_user_ual (target_addr, vptr + n) + ||get_user_ual (target_addrlen, vptr +2 * n) + ||get_user_ual (flags, vptr +3 * n)) { +return -TARGET_EFAULT ; + } + + ret =do_accept4 (sockfd, target_addr, target_addrlen, flags); + } +break ;case SOCKOP_getsockname: {abi_ulong sockfd;
linux-user/syscall_defs.h +1 -0
@@ -27,6 +27,7 @@#define SOCKOP_getsockopt 15#define SOCKOP_sendmsg 16#define SOCKOP_recvmsg 17 +#define SOCKOP_accept4 18#define IPCOP_semop 1#define IPCOP_semget 2
Signature · 1 line
1.8.1.2
Quoted 24 lines · André Hentschel
From: André Hentschel <[email protected]>
Cc Riku Voipio <[email protected]>Signed-off-by André Hentschel <[email protected]>---
See
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/net.h
for the value.
linux-user/syscall.c| 16 ++++++++++++++++linux-user/syscall_defs.h| 1 +2 files changed, 17 insertions(+)linux-user/syscall.c +0
-0@@ -2245,6 +2245,22 @@ static abi_long do_socketcall(int num, abi_ulong vptr) ret =do_accept4 (sockfd, target_addr, target_addrlen,0 ); }break ;
linux-user/syscall.c static abi_long do_socketcall(int num, abi_ulong vptr) · line 2257
Quoted 10 lines
linux-user/syscall.c +10
-0+case SOCKOP_accept4: + { +abi_ulong sockfd; +abi_ulong target_addr, target_addrlen; +int flags; + +if (get_user_ual (sockfd, vptr) + ||get_user_ual (target_addr, vptr + n) + ||get_user_ual (target_addrlen, vptr +2 * n) + ||get_user_ual (flags, vptr +3 * n)) {
I'm not sure, but I think as get_user_ual() get an abi_ulong, flags should be an abi_ulong. Peter ?
Quoted 25 lines
linux-user/syscall.c +6
-0+return -TARGET_EFAULT ; + } + + ret =do_accept4 (sockfd, target_addr, target_addrlen, flags); + } +break ;case
SOCKOP_getsockname:
{abi_ulongsockfd;linux-user/syscall_defs.h +1
-1@@ -27,6 +27,7 @@#define SOCKOP_getsockopt 15#define SOCKOP_sendmsg 16#define SOCKOP_recvmsg 17 +#define SOCKOP_accept4 18#define IPCOP_semop 1#define IPCOP_semget 2 --1.8.1.2
Quoted 30 lines · Laurent Vivier
Quoted 30 lines · André Hentschel
From: André Hentschel <[email protected]>
Cc Riku Voipio <[email protected]>Signed-off-by André Hentschel <[email protected]>---
See
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/net.h
for the value.
linux-user/syscall.c| 16 ++++++++++++++++linux-user/syscall_defs.h| 1 +2 files changed, 17 insertions(+)linux-user/syscall.c +5
-0@@ -2245,6 +2245,22 @@ static abi_long do_socketcall(int num, abi_ulong vptr) ret =do_accept4 (sockfd, target_addr, target_addrlen,0 ); }break ; +case SOCKOP_accept4: + { +abi_ulong sockfd; +abi_ulong target_addr, target_addrlen; +int flags;
Quoted 8 lines
linux-user/syscall.c static abi_long do_socketcall(int num, abi_ulong vptr) · line 2257
Quoted 5 lines
linux-user/syscall.c +5
-0+ +if (get_user_ual (sockfd, vptr) + ||get_user_ual (target_addr, vptr + n) + ||get_user_ual (target_addrlen, vptr +2 * n) + ||get_user_ual (flags, vptr +3 * n)) {I'm not sure, but I think as
get_user_ual()get anabi_ulong, flags should be anabi_ulong.
It's not required for correctness (since get_user_ual always does an abi_ulong sized access of guest memory regardless of the size of its first argument) but I think it would be clearer, yes.
thanks
-- PMM
Riku Voipio
AppliedHi,
Quoted 5 lines · André Hentschel
From: André Hentschel <[email protected]>
Cc Riku Voipio <[email protected]>Signed-off-by André Hentschel <[email protected]>---
See https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/net.h for the value.
Thanks, applied to the linux-user branch. I'm still checking if there are other linux-user patches that need submitting upstream before sending a pull request.
Riku
Quoted 47 lines
linux-user/syscall.c | 16 ++++++++++++++++ linux-user/syscall_defs.h | 1 + 2 files changed, 17 insertions(+)linux-user/syscall.c +16
-0@@ -2245,6 +2245,22 @@ static abi_long do_socketcall(int num, abi_ulong vptr) ret =do_accept4 (sockfd, target_addr, target_addrlen,0 ); }break ; +case SOCKOP_accept4: + { +abi_ulong sockfd; +abi_ulong target_addr, target_addrlen; +int flags; + +if (get_user_ual (sockfd, vptr) + ||get_user_ual (target_addr, vptr + n) + ||get_user_ual (target_addrlen, vptr +2 * n) + ||get_user_ual (flags, vptr +3 * n)) { +return -TARGET_EFAULT ; + } + + ret =do_accept4 (sockfd, target_addr, target_addrlen, flags); + } +break ;case SOCKOP_getsockname: {abi_ulong sockfd;linux-user/syscall_defs.h +1
-0@@ -27,6 +27,7 @@#define SOCKOP_getsockopt 15#define SOCKOP_sendmsg 16#define SOCKOP_recvmsg 17 +#define SOCKOP_accept4 18#define IPCOP_semop 1#define IPCOP_semget 2Signature · 1 line
1.8.1.2