From nobody Fri May 3 08:53:19 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.zoho.com; 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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1487258229436452.43391524182437; Thu, 16 Feb 2017 07:17:09 -0800 (PST) Received: from localhost ([::1]:47270 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceNnu-0005Ys-4Q for importer@patchew.org; Thu, 16 Feb 2017 10:17:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51197) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceHu7-0004R8-AR for qemu-devel@nongnu.org; Thu, 16 Feb 2017 03:59:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceHu3-0000BE-EJ for qemu-devel@nongnu.org; Thu, 16 Feb 2017 03:59:07 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:36508) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceHu3-00009o-8a; Thu, 16 Feb 2017 03:59:03 -0500 Received: by mail-wm0-f66.google.com with SMTP id r18so2008152wmd.3; Thu, 16 Feb 2017 00:59:01 -0800 (PST) Received: from localhost.localdomain ([193.120.165.186]) by smtp.gmail.com with ESMTPSA id 136sm2525427wms.32.2017.02.16.00.58.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 00:59:00 -0800 (PST) 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=8ta5sMQG4miD+wemKLF51LQeHq7Z9+l5W4pccUuP20s=; b=LQIJ4xetLYtHiJFFdf/f0lujfidFGyeu6A7LBkNk1G7h+SDlzRLhmIV9g2N1p6CCdl g89s96rfT9zTGtxxQ8DuzvmxI5T9EPdL+vlbtNXeOtDwpxDI9bhJz9fUTV/1NPAhhYAZ xRp5axsrKBUv5Yt6YTbQhU377h5KylfR+1DsdtTcMg+2oZS43slUX+0qJHPNM/wJil+5 S+AifFaXKOILmmiFTUwQNndrar1r9CzFTA/CYMT3b1yFOIe55KSgv7PEa5YjJWe+3588 uhTLpmrGTab2afvblGzUSPSuLvhAUbYhXDHTduChx31b9bCUJRwCbPyKW/5p58BE/2rj nHbg== X-Gm-Message-State: AMke39lFdPZnG/PZyhwYzOFiFVpV4V9UW39ye+aCeQi1UZtHgaS89QNT2AMMZxTSZOzKuw== X-Received: by 10.28.86.214 with SMTP id k205mr1267522wmb.26.1487235540648; Thu, 16 Feb 2017 00:59:00 -0800 (PST) From: Franklin Snaipe Mathieu To: qemu-devel@nongnu.org Date: Thu, 16 Feb 2017 08:58:57 +0000 Message-Id: <20170216085857.23501-1-snaipe@diacritic.io> X-Mailer: git-send-email 2.11.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 74.125.82.66 X-Mailman-Approved-At: Thu, 16 Feb 2017 09:51:31 -0500 Subject: [Qemu-devel] [PATCH] syscall: fixed mincore(2) not failing with ENOMEM 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: qemu-trivial@nongnu.org, snaipe@arista.com, Riku Voipio , "Franklin \"Snaipe\" Mathieu" , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Franklin \"Snaipe\" Mathieu" The current implementation of the mincore(2) syscall sets errno to EFAULT when the region identified by the first two parameters is invalid. This goes against the man page specification, where mincore(2) should only fail with EFAULT when the third parameter is an invalid address; and fail with ENOMEM when the checked region does not point to mapped memory. Signed-off-by: Franklin "Snaipe" Mathieu Cc: Riku Voipio Cc: Aurelien Jarno --- 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 9be8e9530e..af0dd40631 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -11061,11 +11061,16 @@ abi_long do_syscall(void *cpu_env, int num, abi_l= ong arg1, case TARGET_NR_mincore: { void *a; + ret =3D -TARGET_ENOMEM; + a =3D lock_user(VERIFY_READ, arg1, arg2, 0); + if (!a) { + goto fail; + } ret =3D -TARGET_EFAULT; - if (!(a =3D lock_user(VERIFY_READ, arg1,arg2, 0))) - goto efault; - if (!(p =3D lock_user_string(arg3))) + p =3D lock_user_string(arg3) + if (!p) { goto mincore_fail; + } ret =3D get_errno(mincore(a, arg2, p)); unlock_user(p, arg3, ret); mincore_fail: --=20 2.11.0