aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2016-06-06 19:58:13 +0100
committerRiku Voipio <riku.voipio@linaro.org>2016-06-08 10:13:46 +0300
commitff6dc130794bcd5b2033bc50262a7720285a74c7 (patch)
tree5a67fe1cb59f6e9d88689ba1688e8ce07cdb9bd2
parentffb7ee796ae83b1e4b3c108f8615d54b53872c68 (diff)
linux-user: Use safe_syscall wrapper for accept and accept4 syscalls
Use the safe_syscall wrapper for the accept and accept4 syscalls. accept4 has been in the kernel since 2.6.28 so we can assume it is always present. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
-rw-r--r--linux-user/syscall.c23
1 files changed, 4 insertions, 19 deletions
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 3ccb3676d2..d414dc4771 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -721,6 +721,8 @@ safe_syscall3(ssize_t, recvmsg, int, fd, struct msghdr *, msg, int, flags)
safe_syscall2(int, flock, int, fd, int, operation)
safe_syscall4(int, rt_sigtimedwait, const sigset_t *, these, siginfo_t *, uinfo,
const struct timespec *, uts, size_t, sigsetsize)
+safe_syscall4(int, accept4, int, fd, struct sockaddr *, addr, socklen_t *, len,
+ int, flags)
safe_syscall2(int, nanosleep, const struct timespec *, req,
struct timespec *, rem)
#ifdef TARGET_NR_clock_nanosleep
@@ -3061,19 +3063,6 @@ static abi_long do_sendrecvmmsg(int fd, abi_ulong target_msgvec,
return ret;
}
-/* If we don't have a system accept4() then just call accept.
- * The callsites to do_accept4() will ensure that they don't
- * pass a non-zero flags argument in this config.
- */
-#ifndef CONFIG_ACCEPT4
-static inline int accept4(int sockfd, struct sockaddr *addr,
- socklen_t *addrlen, int flags)
-{
- assert(flags == 0);
- return accept(sockfd, addr, addrlen);
-}
-#endif
-
/* do_accept4() Must return target values and target errnos. */
static abi_long do_accept4(int fd, abi_ulong target_addr,
abi_ulong target_addrlen_addr, int flags)
@@ -3086,7 +3075,7 @@ static abi_long do_accept4(int fd, abi_ulong target_addr,
host_flags = target_to_host_bitmask(flags, fcntl_flags_tbl);
if (target_addr == 0) {
- return get_errno(accept4(fd, NULL, NULL, host_flags));
+ return get_errno(safe_accept4(fd, NULL, NULL, host_flags));
}
/* linux returns EINVAL if addrlen pointer is invalid */
@@ -3102,7 +3091,7 @@ static abi_long do_accept4(int fd, abi_ulong target_addr,
addr = alloca(addrlen);
- ret = get_errno(accept4(fd, addr, &addrlen, host_flags));
+ ret = get_errno(safe_accept4(fd, addr, &addrlen, host_flags));
if (!is_error(ret)) {
host_to_target_sockaddr(target_addr, addr, addrlen);
if (put_user_u32(addrlen, target_addrlen_addr))
@@ -8334,11 +8323,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
#endif
#ifdef TARGET_NR_accept4
case TARGET_NR_accept4:
-#ifdef CONFIG_ACCEPT4
ret = do_accept4(arg1, arg2, arg3, arg4);
-#else
- goto unimplemented;
-#endif
break;
#endif
#ifdef TARGET_NR_bind