From patchwork Thu Apr 3 12:51:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 336628 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B4CEC140096 for ; Thu, 3 Apr 2014 23:52:07 +1100 (EST) Received: from localhost ([::1]:43848 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WVh7l-0004gq-Iy for incoming@patchwork.ozlabs.org; Thu, 03 Apr 2014 08:52:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42520) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WVh77-0004QI-9J for qemu-devel@nongnu.org; Thu, 03 Apr 2014 08:51:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WVh71-0000xt-SK for qemu-devel@nongnu.org; Thu, 03 Apr 2014 08:51:25 -0400 Received: from afflict.kos.to ([92.243.29.197]:33279) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WVh71-0000xT-LA for qemu-devel@nongnu.org; Thu, 03 Apr 2014 08:51:19 -0400 Received: from localhost.localdomain (afflict [92.243.29.197]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by afflict.kos.to (Postfix) with ESMTPSA id B655926565; Thu, 3 Apr 2014 14:51:17 +0200 (CEST) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Thu, 3 Apr 2014 15:51:16 +0300 Message-Id: X-Mailer: git-send-email 1.7.2.5 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 92.243.29.197 Cc: peter.maydell@linaro.org, Petar Jovanovic Subject: [Qemu-devel] [PULL for-2.0] linux-user: pass correct host flags to accept4() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Reviewed-by: Peter Maydell Signed-off-by: Riku Voipio --- 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))