From patchwork Mon Apr 2 17:13:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 10320097 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 A0CCC60375 for ; Mon, 2 Apr 2018 17:21:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9295828A8A for ; Mon, 2 Apr 2018 17:21:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 860A628A95; Mon, 2 Apr 2018 17:21:49 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, FROM_LOCAL_NOVOWEL, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 9C67E28A8E for ; Mon, 2 Apr 2018 17:21:48 +0000 (UTC) Received: from localhost ([::1]:50029 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f339P-0001WS-Pj for patchwork-qemu-devel@patchwork.kernel.org; Mon, 02 Apr 2018 13:21:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36448) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f332L-0004MW-Up for qemu-devel@nongnu.org; Mon, 02 Apr 2018 13:14:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f332K-0004dU-Rj for qemu-devel@nongnu.org; Mon, 02 Apr 2018 13:14:29 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:38176) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f332K-0004d7-L7 for qemu-devel@nongnu.org; Mon, 02 Apr 2018 13:14:28 -0400 Received: by mail-wm0-x244.google.com with SMTP id i3so4827587wmf.3 for ; Mon, 02 Apr 2018 10:14:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/WmIEnaeZ8qvLEGykTGqVxujrlyNTwR253lNIGw7+Y0=; b=jET6KcYZpesEAUFgvuMXFZdaaPhEzkA74jvJkeO5d/KedU6kEcKHbEsEj+dwaW/MgA Zfj0ZU7uppJca57n4iKS7Qsch4iCnbzd0KVS75Wb5H9P5YI7opsDRcgRG+hrxlIO2tAf NjohuwOf8J6X5qWmx9FtECBBvUAiT9vgWmqoRRin5+niLu4Ah9o7IVyiBvjw17ceSM+R W3lug+0vQ86P5IteHTrxnSitYRakVNOIJzabk+8W8gNRRM5X6YAwc+t8eOYFhocegaTx i+HytpE2sPQflRj+XPH8RGDJykTB2nr+jO29ZBD4212WHc0WL3QstHpNiIjPSUOD3vxJ 0ZMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/WmIEnaeZ8qvLEGykTGqVxujrlyNTwR253lNIGw7+Y0=; b=X93bbyZ2tclV4lrzd4gpmiNmrEK9GDQmmaDzmhpUysnmI8V17Nom9PJZvUnKaOmK5t bSR51ztTWfsUw7u40TtzzBnw7Xm44KVYIzfF5YcHDP2N16Jq16h3+miFP4YpdKdF/oqX mhFrihqQUSmhINIP/Y76oyYCc2GFPiMmLm+YBDgeoUP36NyIRtqnpTqAvt2z6oTfYJgf K6V9ztbNFmolg4KILfiN7h8q25qWHnE0GlIvdypvfIgIge0BMMD9o07sgH/GfDiEnj49 RIKQfCDEnqOBoizvAmjYevF0T3a1l32fEFRfupIGejsZ/iRNBGDzSou9D8ltNKwjUS/P 0Bjg== X-Gm-Message-State: ALQs6tDtIiaH/Cgte7mxE9BaUArOeXy2kEEBxPgOb47eQ47BtNl2qdb6 ltBhFKWH6WDdR+ibbQxqTj6Idw== X-Google-Smtp-Source: AIpwx48hM13KyhpEczey0gYYeWgKl1WXXZXcGVCEM0BOS2TLpJHtPLz8xzbAUxGxmlGC6GTEEtXPvg== X-Received: by 10.46.137.203 with SMTP id c11mr6592834ljk.61.1522689267364; Mon, 02 Apr 2018 10:14:27 -0700 (PDT) Received: from octofox.cadence.com (jcmvbkbc-1-pt.tunnel.tserv24.sto1.ipv6.he.net. [2001:470:27:1fa::2]) by smtp.gmail.com with ESMTPSA id s87-v6sm142360lfk.69.2018.04.02.10.14.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Apr 2018 10:14:26 -0700 (PDT) From: Max Filippov To: qemu-devel@nongnu.org Date: Mon, 2 Apr 2018 10:13:50 -0700 Message-Id: <20180402171354.27706-5-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180402171354.27706-1-jcmvbkbc@gmail.com> References: <20180402171354.27706-1-jcmvbkbc@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::244 Subject: [Qemu-devel] [PULL 4/8] linux-user: fix mq_getsetattr implementation 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 , Lionel Landwerlin , Riku Voipio , Laurent Vivier , Max Filippov , Aurelien Jarno , "Kirill A . Shutemov" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP mq_getsetattr implementation does not set errno correctly in case of error. Also in the presence of both 2nd and 3rd arguments it calls both mq_getattr and mq_setattr, whereas only the latter call would suffice. Don't call mq_getattr in the presence of the 2nd argument. Don't copy output back to user in case of error. Use get_errno to set errno value. This fixes test rt/tst-mqueue2 from the glibc testsuite. Cc: Lionel Landwerlin Cc: Kirill A. Shutemov Cc: Riku Voipio Cc: Aurelien Jarno Cc: Laurent Vivier Reviewed-by: Laurent Vivier Signed-off-by: Max Filippov --- linux-user/syscall.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 18ea79140f16..d51e2a00ee31 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -12092,15 +12092,16 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, { struct mq_attr posix_mq_attr_in, posix_mq_attr_out; ret = 0; - if (arg3 != 0) { - ret = mq_getattr(arg1, &posix_mq_attr_out); - copy_to_user_mq_attr(arg3, &posix_mq_attr_out); - } if (arg2 != 0) { copy_from_user_mq_attr(&posix_mq_attr_in, arg2); - ret |= mq_setattr(arg1, &posix_mq_attr_in, &posix_mq_attr_out); + ret = get_errno(mq_setattr(arg1, &posix_mq_attr_in, + &posix_mq_attr_out)); + } else if (arg3 != 0) { + ret = get_errno(mq_getattr(arg1, &posix_mq_attr_out)); + } + if (ret == 0 && arg3 != 0) { + copy_to_user_mq_attr(arg3, &posix_mq_attr_out); } - } break; #endif