From patchwork Thu Sep 22 15:06:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandar Markovic X-Patchwork-Id: 9345757 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0C4656077A for ; Thu, 22 Sep 2016 16:03:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF3662AB72 for ; Thu, 22 Sep 2016 16:03:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DFA542ABA4; Thu, 22 Sep 2016 16:03:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 848772AB72 for ; Thu, 22 Sep 2016 16:03:27 +0000 (UTC) Received: from localhost ([::1]:51832 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn6T8-0007h5-GD for patchwork-qemu-devel@patchwork.kernel.org; Thu, 22 Sep 2016 12:03:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50794) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn5dI-0001Ux-Rq for qemu-devel@nongnu.org; Thu, 22 Sep 2016 11:09:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bn5dD-0004pG-PA for qemu-devel@nongnu.org; Thu, 22 Sep 2016 11:09:51 -0400 Received: from mx2.rt-rk.com ([89.216.37.149]:46491 helo=mail.rt-rk.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn5dD-0004p9-Ce for qemu-devel@nongnu.org; Thu, 22 Sep 2016 11:09:47 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id A068B1A220F; Thu, 22 Sep 2016 17:09:46 +0200 (CEST) X-Virus-Scanned: amavisd-new at rt-rk.com Received: from mcs19.domain.local (mcs19.domain.local [10.10.13.51]) by mail.rt-rk.com (Postfix) with ESMTPSA id 830E41A1E2E; Thu, 22 Sep 2016 17:09:46 +0200 (CEST) From: Aleksandar Markovic To: qemu-devel@nongnu.org, riku.voipio@iki.fi, laurent@vivier.eu, peter.maydell@linaro.org, petar.jovanovic@imgtec.com, miodrag.dinic@imgtec.com, aleksandar.rikalo@imgtec.com, aleksandar.markovic@imgtec.com Date: Thu, 22 Sep 2016 17:06:34 +0200 Message-Id: <20160922150646.78163-7-aleksandar.markovic@rt-rk.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20160922150646.78163-1-aleksandar.markovic@rt-rk.com> References: <20160922150646.78163-1-aleksandar.markovic@rt-rk.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 89.216.37.149 Subject: [Qemu-devel] [PATCH v6 06/10] 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: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 7d7a57f..93dacd7 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -11402,16 +11402,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;