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: 27686 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f200.google.com (mail-ob0-f200.google.com [209.85.214.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1148F2036E for ; Thu, 3 Apr 2014 12:52:21 +0000 (UTC) Received: by mail-ob0-f200.google.com with SMTP id gq1sf6708693obb.11 for ; Thu, 03 Apr 2014 05:52:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=PRpByXoWkxLHwj4Akl/GjKg9XiI9CY6/JSOWwa1tDDo=; b=LD1cHpfc5ClN0giBwNLWIEQAzD4AnrLKlTp7mAklHARaXRxFKpU72h3RXsyNbaDGIj mIAPQ6zc8YIt7e+8fm5Alv7OYqJQmHJIBGc3riJCAx4jU3skujPaCJLdT/RCrvDnNjKm u+6KuhQ3tor1tLQ+lUIYtYgNqYqfUB1UjRPQpyz9mGJTgfJVYFhuxmp87Vb1MrmyOFEV GedxtCI3cOQdgmGbFZb6T/9XZOrJNVpnpIWcuy+J2ZSTtr0VYpgYwSVnrAEcB7BXjx+i ZwkBmmJmOTXvCJnjqOOI25I4u4AMbmbOzx5zWm0gnFAoFuc2VWkd09pYa/x2AXge0tmu yKsQ== X-Gm-Message-State: ALoCoQmY9cDa1/E1cGPer6ZFvel5/tglzWsmB9GOcne/hDZbON4M16pyZxA1JMzvUUFun67FvCXO X-Received: by 10.43.161.202 with SMTP id mh10mr3345283icc.23.1396529541604; Thu, 03 Apr 2014 05:52:21 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.48.202 with SMTP id o68ls637551qga.53.gmail; Thu, 03 Apr 2014 05:52:21 -0700 (PDT) X-Received: by 10.221.37.1 with SMTP id tc1mr2822839vcb.32.1396529541504; Thu, 03 Apr 2014 05:52:21 -0700 (PDT) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by mx.google.com with ESMTPS id b5si213441vej.29.2014.04.03.05.52.21 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 03 Apr 2014 05:52:21 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.176; Received: by mail-ve0-f176.google.com with SMTP id db11so215146veb.21 for ; Thu, 03 Apr 2014 05:52:21 -0700 (PDT) X-Received: by 10.220.47.201 with SMTP id o9mr566144vcf.65.1396529541423; Thu, 03 Apr 2014 05:52:21 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.12.8 with SMTP id v8csp25466vcv; Thu, 3 Apr 2014 05:52:21 -0700 (PDT) X-Received: by 10.140.88.85 with SMTP id s79mr6782871qgd.70.1396529540399; Thu, 03 Apr 2014 05:52:20 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id v6si2090415qas.45.2014.04.03.05.52.20 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 03 Apr 2014 05:52:20 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:43850 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WVh7z-0005O5-RH for patch@linaro.org; Thu, 03 Apr 2014 08:52:19 -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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: riku.voipio@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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))