From patchwork Tue Jan 23 14:47:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 125522 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp1800297ljf; Tue, 23 Jan 2018 06:48:50 -0800 (PST) X-Google-Smtp-Source: AH8x226zWY2Ea4Q/v3WazMWrrC3G86BPXsxROAjWVVY9EwoFIbMgRbOaybDxEkRrSdcd1IDTed6j X-Received: by 10.37.102.2 with SMTP id a2mr2623030ybc.496.1516718929936; Tue, 23 Jan 2018 06:48:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516718929; cv=none; d=google.com; s=arc-20160816; b=uht1zLl0/ez5on56ubjNJjQCxAlLfjjiJNt0N3vFybT8sP2AWQEHj9ErpmbVYHdz/Q Q71gUZI8BjDTy5naHbIJCCobWyxOEI556QljcoNKTr0Y3a1lSp6UxNaIPo71rjbtxtN0 hAGV0bkWNHsJH/CqvDMHNfb0ueWjtc8y2kbmXx/+/SyvQeRRyxrF4Az/+Q+ZKDd6njFR rsK+bx7sZhcwZnSF6ZlZzOI4MVmxXKgsKC8/THTHpSsIUXcEkbKHdwomxBzyywPA80T2 wVoXVwhvye4mUy74nLMfzr9Yi0x9lw36DTBMbwfqBuEIKKnTO3sSZaYmpOhxDm1lXsoL yamg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=UCkj6YAZeowd4BKshfLJYQ8nizK15B7S8fUoZogrPCk=; b=JnnKjRO1vn7F1eSjUC92wkVtpi9rkCgtW0fcjOBsLrIB6oNdNL4RU7Yu770yrq65NW 25ulyKlZubDi/AI0DAGeQQOxe7mzWkjnggmNAH97PVWhzHNzfNy9S+yOzhnFy3IvxuG3 aw6qsqDNBiiJGcLY4bvwNLyJXP9DVpgVpvYTuxQlY1pj7sHbct1jlH1S8JN5Kmxbbya7 ut0/BAVWATPi6gKqVDwAo1WgDRbbQ8Fzs5JxJQPc314ws6m9efFuwP35n2S2bgTrWgqQ 3oYAMr7hzoDfri0ABPmyLDHvgeLz6Z3bWbciJUzhxDo2vMcYhXO3zeVxPa9h4jlDSU8H Ctaw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id c84si499439ybb.630.2018.01.23.06.48.49 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 23 Jan 2018 06:48:49 -0800 (PST) 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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:33595 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1edzsX-00078x-7p for patch@linaro.org; Tue, 23 Jan 2018 09:48:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43441) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1edzs2-00075d-3t for qemu-devel@nongnu.org; Tue, 23 Jan 2018 09:48:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1edzry-0002MS-7W for qemu-devel@nongnu.org; Tue, 23 Jan 2018 09:48:18 -0500 Received: from mout.kundenserver.de ([212.227.17.10]:61908) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1edzrx-0002KF-Ta for qemu-devel@nongnu.org; Tue, 23 Jan 2018 09:48:14 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue102 [212.227.15.183]) with ESMTPSA (Nemesis) id 0MgOZS-1eP6BZ3ouM-00Nhaa; Tue, 23 Jan 2018 15:48:12 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Tue, 23 Jan 2018 15:47:59 +0100 Message-Id: <20180123144807.5618-6-laurent@vivier.eu> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180123144807.5618-1-laurent@vivier.eu> References: <20180123144807.5618-1-laurent@vivier.eu> X-Provags-ID: V03:K0:luA8hJq+VZuSvonZgjeZBULZ9JP7uhkJSi7+fPKsdu8kK0cejUb TJX4iCfP9IC8yYDKQ1ZI5MvfhC1GHGgKuPb8WytFs+QE31cjPXukzQsWdIMGgui/SBZr7zH 29oUcxgiEIKiCcNSdrwcGySUR5Z8QNXBc8L739h7yzTNVuGxQrFIEI10FtM6vB3F6blw/uu 9SlaM5tt5QP9iAGJ3cQ1Q== X-UI-Out-Filterresults: notjunk:1; V01:K0:qrq+Ggasjxw=:kE6qD1oqFWa+Aj+okQLnkV FA1qzVFP+mu6FNMG02zpP+wl1XnMDJXFGTavDISe4DO/E0xc20FbZDK28gQGFU7vG+eNdwYgG 1jlWjXIUZX4BeI7mMm0EyqzHHGgRS+0NnMpCvwuR8lf2Dyx+pff7MMD8+Gxcb1aIcwk/B+EjI WkSBZaYjY7lqlpLoPCrO05bmOUK568VjJlPyLxFDWs8viE7GZLMmMmPO/Btn6Kp1PvveB7na6 0jJj3Yc80IgbHsoDDYD932KNK9VWDH1dRsKAj4tLZ3a0L7DlU3dNlw4wcyX+9pPJ8T5yuyudZ gEsk73bX6zrpA3aQt5kqic1EU4JrZ9pBAFJZIqY6UTO8E5x7m000705i5o27VrCYSiGcN9OkW kf3ZQCcjxps+/BGgf99EHIZML31cr6kryGracklktbl+Ixgy6E9QxDJnF6HvnVQ2M/ABmnthx JwYvjTkTdNt1A43FFPDT5BHymYL4EjmBQZNU3dTPOiv9XRoFrOMZ4GDIZvG9/tYI3Tomnn9ea YU44vUeX6DVsM2T8iXc7Qzf9a4Ky1e6p3lunOM1je97VkUdpg1uZNJSowC/L0d4YUOCL4WT/X P3Zl3J2M8VqdVLLtRrkCOoOu3PA0RLvfJSLMA/SbI2Uc1YAriO793r8NkEH/PzOc3TCxeTpQS SDb9NIi4GPLSiZ8F7mf6y9NXJQKXNbkAX4j70X8YlUcwul5SVfKvRCHUBOq7LgQgkedFaqOe4 YguJxvzDQkHhQF2YN6gia5kqBzC/qAL5wLfvzQ== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.17.10 Subject: [Qemu-devel] [PULL 05/13] linux-user: Translate flags argument to dup3 syscall X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell The third argument to dup3() is a flags word which may be O_CLOEXEC. We weren't translating this flag from target to host value, which meant that if the target used a different value from the host (eg sparc guest and x86 host) the dup3() call would fail EINVAL. Do the correct translation. Fixes: https://bugs.launchpad.net/qemu/+bug/1704658 Reported-by: Bruno Haible Signed-off-by: Peter Maydell Reviewed-by: Laurent Vivier Message-Id: <1513351080-25917-1-git-send-email-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) -- 2.14.3 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 39553c81b6..41ded90ee6 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8490,11 +8490,19 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, #endif #if defined(CONFIG_DUP3) && defined(TARGET_NR_dup3) case TARGET_NR_dup3: - ret = get_errno(dup3(arg1, arg2, arg3)); + { + int host_flags; + + if ((arg3 & ~TARGET_O_CLOEXEC) != 0) { + return -EINVAL; + } + host_flags = target_to_host_bitmask(arg3, fcntl_flags_tbl); + ret = get_errno(dup3(arg1, arg2, host_flags)); if (ret >= 0) { fd_trans_dup(arg1, arg2); } break; + } #endif #ifdef TARGET_NR_getppid /* not on alpha */ case TARGET_NR_getppid: