From nobody Sat Apr 27 21:50:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1522513529204581.9087670898249; Sat, 31 Mar 2018 09:25:29 -0700 (PDT) Received: from localhost ([::1]:34784 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f2JJe-0008EP-9m for importer@patchew.org; Sat, 31 Mar 2018 12:25:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60875) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f2JId-0007gQ-Sy for qemu-devel@nongnu.org; Sat, 31 Mar 2018 12:24:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f2JIc-0005Ja-ST for qemu-devel@nongnu.org; Sat, 31 Mar 2018 12:24:15 -0400 Received: from mail-lf0-x241.google.com ([2a00:1450:4010:c07::241]:33120) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f2JIc-0005JF-Kg for qemu-devel@nongnu.org; Sat, 31 Mar 2018 12:24:14 -0400 Received: by mail-lf0-x241.google.com with SMTP id x70-v6so9017605lfa.0 for ; Sat, 31 Mar 2018 09:24:14 -0700 (PDT) Received: from octofox.hsd1.ca.comcast.net. (jcmvbkbc-1-pt.tunnel.tserv24.sto1.ipv6.he.net. [2001:470:27:1fa::2]) by smtp.gmail.com with ESMTPSA id h86-v6sm2153865lfl.73.2018.03.31.09.24.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 31 Mar 2018 09:24:12 -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; bh=CDWpI1Ye3wPRqkLNpw8NxGqdhRn5fDyYD1S4iJgy9Vo=; b=sgM9M4YsqaH3yRgfYV34qvLYkHMIIG//mm5L6n8/S5pMztRlz8k2WtZI7Gd5hMPyr0 /0VD/8KCfX0WhbRRf1rpNd6h4d+OxSSc52dCVjPr7IjlciRnHlXeUX2Zxq+ZwzWYtRcp ynmmY1WHTMdIVZJK3Nsg1Yjk1sK4BC+CXj2NTPbj3RH9Wt7g7l+75l2RIRK9TcO5nCE8 kt5dn2f9u5BHadfpyhfniekUDENAv1gjNrofVwLey/LIouQAo+r9IzLRl46PIGVpgg+u WNdNGMAsYUsMLQ8ydNtDtkJRnlHhsMz5OjXfuwnSm93foy2orVrDBHsIMVvocb+lkLWG IlfQ== 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; bh=CDWpI1Ye3wPRqkLNpw8NxGqdhRn5fDyYD1S4iJgy9Vo=; b=ZwMUHhr6J6zmCPnhV0BD4+cwlhJCUZjlMfJB63zLDB/Sj92GBdOpWMpya+/fDPU8xb jCKMl3aqvXRPabRQKC3496hzvGq3OsdauCUILAU5zQxTTGnTRrLqxcS0BIwdzwmkGVrX BQhA7S4cqRHSF3GntqgfAh1IPTPIV9Ikd40LdwQIkkv12jFHdOSXuekdNlPghFYfv+El IF4durSEaOim/erBJtzzKqsixzqL5ravJoqRXorhnlrETK+JwtawdmtqzXsA9OSdSPCx yHevjnd+w+GyZG7K/HUCUjqg0KBuHMRQ3bMtwwBZTVjuoW7nBQJNWQaBHWXRAMt18xGl azMA== X-Gm-Message-State: ALQs6tD0ZpOyXlVMKSymquIRU5zPvG0vHsQnVsB4WUSV4xRKPRu/a9jl kzlk7g9UxPKAlSGRyZQARau6KA== X-Google-Smtp-Source: AIpwx4//YZHcKBtXzP9+5nryprupqlD6M8BebByuuB8Le0UpYM7xDEACm6RD6cez4gYAKxhS1O3mbw== X-Received: by 2002:a19:7708:: with SMTP id s8-v6mr1909958lfc.93.1522513453051; Sat, 31 Mar 2018 09:24:13 -0700 (PDT) From: Max Filippov To: qemu-devel@nongnu.org Date: Sat, 31 Mar 2018 09:23:36 -0700 Message-Id: <20180331162336.20158-1-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.11.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4010:c07::241 Subject: [Qemu-devel] [PATCH] 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: Lionel Landwerlin , Riku Voipio , Laurent Vivier , Max Filippov , "Kirill A . Shutemov" , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 3rd argument. 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 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..8b364551c311 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_l= ong arg1, { struct mq_attr posix_mq_attr_in, posix_mq_attr_out; ret =3D 0; - if (arg3 !=3D 0) { - ret =3D mq_getattr(arg1, &posix_mq_attr_out); - copy_to_user_mq_attr(arg3, &posix_mq_attr_out); - } if (arg2 !=3D 0) { copy_from_user_mq_attr(&posix_mq_attr_in, arg2); - ret |=3D mq_setattr(arg1, &posix_mq_attr_in, &posix_mq_att= r_out); + ret =3D mq_setattr(arg1, &posix_mq_attr_in, &posix_mq_attr= _out); + } else if (arg3 !=3D 0) { + ret =3D mq_getattr(arg1, &posix_mq_attr_out); } - + if (arg3 !=3D 0) { + copy_to_user_mq_attr(arg3, &posix_mq_attr_out); + } + ret =3D get_errno(ret); } break; #endif --=20 2.11.0