Received: from eggs.gnu.org ([2001:4830:134:3::10]:33301) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WUeLU-0006s3-2f for qemu-devel@nongnu.org; Mon, 31 Mar 2014 11:42:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WUeLO-0005jd-Ux for qemu-devel@nongnu.org; Mon, 31 Mar 2014 11:41:56 -0400 Received: from mx2.rt-rk.com ([89.216.37.149]:44843 helo=mail.rt-rk.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WUeLO-0005jO-O3 for qemu-devel@nongnu.org; Mon, 31 Mar 2014 11:41:50 -0400 From: Petar Jovanovic Date: Mon, 31 Mar 2014 17:41:23 +0200 Message-Id: <1396280483-114396-1-git-send-email-petar.jovanovic@rt-rk.com> Subject: [Qemu-devel] [PATCH v2] linux-user: pass correct host flags to accept4() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, riku.voipio@linaro.org, petar.jovanovic@imgtec.com From: Petar Jovanovic Flags NONBLOCK and CLOEXEC can have different values on the host and the guest, so set correct host values before calling accept4(). This fixes several issues with accept4 system call and user-mode of QEMU. Signed-off-by: Petar Jovanovic --- v2: - use target_to_host_bitmask() (per comment from Peter Maydell) linux-user/syscall.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 2eac6d5..9864813 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -2062,9 +2062,12 @@ static abi_long do_accept4(int fd, abi_ulong target_addr, socklen_t addrlen; void *addr; abi_long ret; + int host_flags; + + host_flags = target_to_host_bitmask(flags, fcntl_flags_tbl); if (target_addr == 0) { - return get_errno(accept4(fd, NULL, NULL, flags)); + return get_errno(accept4(fd, NULL, NULL, host_flags)); } /* linux returns EINVAL if addrlen pointer is invalid */ @@ -2080,7 +2083,7 @@ static abi_long do_accept4(int fd, abi_ulong target_addr, addr = alloca(addrlen); - ret = get_errno(accept4(fd, addr, &addrlen, flags)); + ret = get_errno(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)) -- 1.7.9.5