From patchwork Tue Oct 18 13:21:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 78038 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp885762qge; Tue, 18 Oct 2016 06:28:47 -0700 (PDT) X-Received: by 10.55.135.1 with SMTP id j1mr512845qkd.46.1476797327447; Tue, 18 Oct 2016 06:28:47 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id l16si21010889qtl.31.2016.10.18.06.28.47 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 18 Oct 2016 06:28:47 -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; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org; 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; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:41527 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwURi-0002Z4-S1 for patch@linaro.org; Tue, 18 Oct 2016 09:28:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53707) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwUL9-0006Dw-KQ for qemu-devel@nongnu.org; Tue, 18 Oct 2016 09:22:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bwUL8-0000ce-PE for qemu-devel@nongnu.org; Tue, 18 Oct 2016 09:21:59 -0400 Received: from mail-lf0-x22d.google.com ([2a00:1450:4010:c07::22d]:35866) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1bwUL8-0000c3-GD for qemu-devel@nongnu.org; Tue, 18 Oct 2016 09:21:58 -0400 Received: by mail-lf0-x22d.google.com with SMTP id b75so346717242lfg.3 for ; Tue, 18 Oct 2016 06:21:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7roZiGAFRKHimJKr/vO8jLsbOt/YDW+jTDUOOmKHcHc=; b=CuzMIlGrP3PqplHX7qECUr5rqtD47oW7EQzNBJqk3yk7FMmFjZxGlmuNFOg68P8x9U A3+XIVGBha4bMlV9P5AQDQyTLIpKi+l8GgETx9Pe3kIfDLJatkMWXWylkGD1Ur9S7f4R oueOeMWLrLR/ezbdpDlN6n5pQxcgA5dmed8KQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7roZiGAFRKHimJKr/vO8jLsbOt/YDW+jTDUOOmKHcHc=; b=agcRyIsLGCVGiBccRweorR9vcZbTrWsYWF+sLlEqzW/L0X6wWZRme30IZmWXCHdBDz D6dO09SobpvlTExbXivFEsMPwrSDN0L661MnvxpO2ycfk/0Wvqd+xeHPMDAToQDe69O0 vxkvMnEWSzrUZ+Nec3lGcnSdsVYxmZj08iCB5eHg6tAUo73uNWA1Q0Kv4PYXK30nbf/V eEXDd7A8EIyzEw5R2m5TR8HzOj5DebX6un662Rx8oWDxsJDKLao26NKGaUwhcpoRrVr9 YoiOQnzTY5x6Ig6sMvwU1sXiMCuZDXfJKa6ndaDI7RaIScsJEQ/DfAXRdljVoe2QddnM hQsQ== X-Gm-Message-State: AA6/9Rn/ySFNnC7Akw0gdPmjVobfYRGBvCcsu1sZtrBaJ66TL2SzNzQBbbwe9b9aeaggcpx0 X-Received: by 10.25.196.85 with SMTP id u82mr479225lff.125.1476796915954; Tue, 18 Oct 2016 06:21:55 -0700 (PDT) Received: from beaming.home (91-157-170-157.elisa-laajakaista.fi. [91.157.170.157]) by smtp.gmail.com with ESMTPSA id 201sm9535359ljf.48.2016.10.18.06.21.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Oct 2016 06:21:55 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Tue, 18 Oct 2016 16:21:31 +0300 Message-Id: <634dff4055269f650de46d9f0b46ce940764d440.1476796525.git.riku.voipio@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::22d Subject: [Qemu-devel] [PULL v2 03/22] linux-user: Fix mq_open() syscall support 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 , Aleksandar Markovic Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Aleksandar Markovic Conversion of file creation flags (O_CREAT, ...) from target to host was missing. Also, this patch implements better error handling. Signed-off-by: Aleksandar Markovic Signed-off-by: Riku Voipio --- linux-user/syscall.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) -- 2.1.4 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 88007e0..e031ecf 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -11476,16 +11476,18 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_mq_open) && defined(__NR_mq_open) case TARGET_NR_mq_open: { - struct mq_attr posix_mq_attr, *attrp; + struct mq_attr posix_mq_attr; + int host_flags; + host_flags = target_to_host_bitmask(arg2, fcntl_flags_tbl); + if (copy_from_user_mq_attr(&posix_mq_attr, arg4) != 0) { + goto efault; + } p = lock_user_string(arg1 - 1); - if (arg4 != 0) { - copy_from_user_mq_attr (&posix_mq_attr, arg4); - attrp = &posix_mq_attr; - } else { - attrp = 0; + if (!p) { + goto efault; } - ret = get_errno(mq_open(p, arg2, arg3, attrp)); + ret = get_errno(mq_open(p, host_flags, arg3, &posix_mq_attr)); unlock_user (p, arg1, 0); } break;