From patchwork Thu Feb 16 14:38:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 728789 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 3vPLV01YW2z9s8L for ; Fri, 17 Feb 2017 03:00:40 +1100 (AEDT) Received: from localhost ([::1]:47518 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceOU1-0005P0-KE for incoming@patchwork.ozlabs.org; Thu, 16 Feb 2017 11:00:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53840) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceNCo-0000kg-A6 for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:38:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceNCn-0002Pl-5a for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:38:46 -0500 Received: from mout.kundenserver.de ([217.72.192.75]:60292) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceNCm-0002OY-Qu for qemu-devel@nongnu.org; Thu, 16 Feb 2017 09:38:45 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.183]) with ESMTPSA (Nemesis) id 0MgOVK-1czsaX1sZC-00NkEe; Thu, 16 Feb 2017 15:38:23 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Thu, 16 Feb 2017 15:38:08 +0100 Message-Id: <20170216143816.2384-7-laurent@vivier.eu> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170216143816.2384-1-laurent@vivier.eu> References: <20170216143816.2384-1-laurent@vivier.eu> X-Provags-ID: V03:K0:j9z1yr/dkNsEyoeBoP6c+Jfc998INXMgerkssQ2BZzmfrU2g94w dDzZ83czc5NQ070GTrhPrfvCAKwFbF/Pv/5yAWF1239lisLzjrj0Z+YgxCjcezr3vEJqNIP pA9Xai/iH4TSGQBRpPIsKY5aAto74I9QVmeTb2T2QUbaltylJQSGsSRuT+8n94JlkeB7T9m wRDI50Q19SjEMQIiG3/VQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:9a40krdKS10=:49XWz1HusQlR9CBa5DJnE5 S7E+iwPpdqMhcVoIhc7hXkY3mzx9fLvV0/HuAbHHE1LCqFWbxJ3IxoNpaTGfGpB+jz9HHEHmm WPZOPnbJc99Nl7xapUi8JA///ZYAMijN2AECxdx7SxVC8GPL28CCaaumY4+aRKEXS2zC2la94 8yuYB4HQNkk37qfwkM10UjxOasRBXscwgOJHYbUncW72cR6yD00lvaWp3+KZYVYpbPX+6ewAY 6+Bk2EogZNWk9z9MgaC9h2Igpop7L3d8+S7lDvSVrZO2GsXFraRNzP9V3pr80xV7uSo19N+Zy 7f9dNubljUZU5/nLaQEl3NYu2/25ORhDf6OlgLocqzuc6oX30kkYQyq8HJNB1F6IvVIO6JEvi 5altGEOa+i0SkwI7LYXvkk8exjOpvIDOap6T5dZw6/5UKggVuttXfhUKrX7Vdvihp18t1cgZ8 QFffe2SXT7rYbNwaxF+PC2L87TDYxzlvD6OUqTD4SOQGN3/xo/VUO+DxoVX61R7A0yLsaTsCh 2VUHIqzR3GSUYT7ekSyD5AZ9K7NIvuFunr5B8UKI43yYfTLyuxFrexGI2YvCCa76GW0XIARCd N4scFbHutH+UyvnZfTsOnDS9SSmldrX9i7clUh7Qjt+TmGvgLzy1XllcH/zj0/VPY41F67qfr wpTs2ZQp7dYNeFX+isDt/71KELOe4E3LOcRzx9/nTiTPf1TOG7skRxs9ZKtpHWzjB8HQ= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 217.72.192.75 Subject: [Qemu-devel] [PULL v2 06/14] linux-user: Fix mq_open 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: Lena Djokic , Riku Voipio , Riku Voipio Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Lena Djokic If fourth argument is NULL it should be passed without using lock_user function which would, in that case, return EFAULT, and system call supports passing NULL as fourth argument. Signed-off-by: Lena Djokic Reviewed-by: Peter Maydell Signed-off-by: Riku Voipio --- linux-user/syscall.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 3e88dd1..c1d6f76 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -11583,17 +11583,22 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, case TARGET_NR_mq_open: { struct mq_attr posix_mq_attr; + struct mq_attr *pposix_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; + pposix_mq_attr = NULL; + if (arg4) { + if (copy_from_user_mq_attr(&posix_mq_attr, arg4) != 0) { + goto efault; + } + pposix_mq_attr = &posix_mq_attr; } p = lock_user_string(arg1 - 1); if (!p) { goto efault; } - ret = get_errno(mq_open(p, host_flags, arg3, &posix_mq_attr)); + ret = get_errno(mq_open(p, host_flags, arg3, pposix_mq_attr)); unlock_user (p, arg1, 0); } break;