From patchwork Mon Oct 17 13:24:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 682950 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 3syJrH1DYDz9s9c for ; Tue, 18 Oct 2016 00:26:23 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b=j2gLf6wi; dkim-atps=neutral Received: from localhost ([::1]:33059 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bw7vn-0004JF-5e for incoming@patchwork.ozlabs.org; Mon, 17 Oct 2016 09:26:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38309) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bw7uN-00034v-Uy for qemu-devel@nongnu.org; Mon, 17 Oct 2016 09:24:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bw7uM-0003Aa-VA for qemu-devel@nongnu.org; Mon, 17 Oct 2016 09:24:51 -0400 Received: from mail-lf0-x22e.google.com ([2a00:1450:4010:c07::22e]:35803) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1bw7uM-0003AA-NB for qemu-devel@nongnu.org; Mon, 17 Oct 2016 09:24:50 -0400 Received: by mail-lf0-x22e.google.com with SMTP id l131so242723367lfl.2 for ; Mon, 17 Oct 2016 06:24:50 -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=j2gLf6wiEPIN081mIIEoHCqKnxBH9TCKrgqYgTvrU1H9YwwguCM1uiQo0e4LSBSE4U mE4+7ET/5Hzqhh7Gl380zrQR3xhS8yJuvz5RCYIG6ah1ldDAar9aTM4zodIX5tROspi5 VFYLDtjHlnYQc3ttVD5dSS0j98JL6GwnF7cqY= 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=JpaOYF9FWxhJWAykJyLE6VUsFtrQT2fSk+sBBFTLV/s1zhV6x/xzdZohmyd3f5tc5c DSGnfA0gpYpGdXlpxj86u6fgHvNwzwR35mXlEYZqgwSLfw6aw4Wme4KLKQM/+FMMUOvu 0nd1GMKRYyUhX7nsC9zyrPowLwzON5y9EmvYtTm2Scb9yNXIQl7EXhXYOjy03TlzSxaZ Fj59QX+E6hw+aRil05cWFNsAVORId976b71FcDBrBdTxl44/8wk5aMR0zZtNjJyqEI/W o5+BTUlTh6hi9LwRKtu/i8hYXytoHRksDS9G7f9myFsJ0SHQmDlWUAJQP/b6nug5ugFq sE7A== X-Gm-Message-State: AA6/9RlfM8pT6LkoxUTUl+BY0opeihx6Dhw6xF3g12Uoa61TKzln/MJU1XBBa/DpVf9it1qx X-Received: by 10.25.27.207 with SMTP id b198mr13132035lfb.18.1476710686546; Mon, 17 Oct 2016 06:24:46 -0700 (PDT) Received: from beaming.home (91-157-170-157.elisa-laajakaista.fi. [91.157.170.157]) by smtp.gmail.com with ESMTPSA id y81sm7782857lff.29.2016.10.17.06.24.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Oct 2016 06:24:45 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Mon, 17 Oct 2016 16:24:21 +0300 Message-Id: <634dff4055269f650de46d9f0b46ce940764d440.1476710352.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::22e Subject: [Qemu-devel] [PULL 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+incoming=patchwork.ozlabs.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(-) 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;