From nobody Thu Nov 6 19:09:15 2025 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 148823541629574.57789693361588; Mon, 27 Feb 2017 14:43:36 -0800 (PST) Received: from localhost ([::1]:57348 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciU10-0000p8-VC for importer@patchew.org; Mon, 27 Feb 2017 17:43:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39838) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciTrw-0001cv-9Q for qemu-devel@nongnu.org; Mon, 27 Feb 2017 17:34:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciTrs-0005Jg-GD for qemu-devel@nongnu.org; Mon, 27 Feb 2017 17:34:12 -0500 Received: from mout.kundenserver.de ([217.72.192.75]:58676) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ciTrs-0005Bp-5i for qemu-devel@nongnu.org; Mon, 27 Feb 2017 17:34:08 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue102 [212.227.15.183]) with ESMTPSA (Nemesis) id 0MJl7U-1chNvw3LaG-001AJH; Mon, 27 Feb 2017 23:33:45 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Mon, 27 Feb 2017 23:33:37 +0100 Message-Id: <20170227223337.17434-7-laurent@vivier.eu> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170227223337.17434-1-laurent@vivier.eu> References: <20170227223337.17434-1-laurent@vivier.eu> X-Provags-ID: V03:K0:F2iPNuISKQYWXpq38uRwDkCXPRnJ9MNmjGpZSiwEEObHkRUIZ5U 95xW4KAtJdBEuzRSvjXCrjsleIrXn7DKVDB3jqSP2YTkQJipBs9IntCPk4k96RZOOijqCmA RP/yYBYIIsziBQVTyl/7674+S6NmNLDwVDG2vdq77Ob6kxR/XjXYKisxQLVd/SbOSWR2mLu SQtNk1ZJNohmlASVclxpg== X-UI-Out-Filterresults: notjunk:1;V01:K0:LKt540LXeqE=:W23KyTUTgL5nx3ZRe6X7mT pvPQ1k4V16gWVTpbpUMYxv2N2IxKy0x/e/dhw892NMEKIDPKYeoVgB/h/ZP2nEpM8z0RXRcuk 13MnloSWAJZgHqE6QhcmJJcISdqyGrKbTQYN12j/bvRsFwT0/aNp3KTVeNEQzt+JcxWlJXM0n Wd49hYxRcj5OzTdwM5iOJCg6IsaRh3RXGPLdYfUvjKxZ89jWATP2Yj1MOPbCRooDe+KLPAGYB FBfzWzjsYFAkANELZfa4wQ/6ccBwbcCZijRL+ir48/VICjpt1IBxfbKZiRnV79Rb8OZCb5v2Z Hmz1wFl0wQ9ukdfJZ/vmEZHp3qFeq3rp3Uq6pHIvrtHamMACeSP55jgnpyw/Ew+eBEOCs+wG9 akaa7VWRbtU+4o4T3qNyvyymtfgGH0/cwamjwyUz/oRQOLxPef3oRklYAqVxz3iEBTCvIvHY0 Q6xrGsKrTMgMmo4JBk2jfADhMjyOdEyfG3vfJwTTBd0SHfEg+8gGRY2er8f09cpwbbbZuQS3f wlh+kSy5neQDD7d9yn9diG7aHsgv0ELoy2J22lgtgp6j406kLyTZlmmG0o8wSOVGBzzNwuTv+ 9cQ38BKKhXFwi1XSsQJonimsW53TvscZWijpK/y9PLVnluF+Oyzp7tg6j5/5sgNhy9pH+eGfL lzhUNKFBmUAJXN6EX4sp4DPbAO8WnfO6E49w+IWhB2xg4e7AMI2+IeQk1Jie520wCx2M= 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 6/6] 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: Riku Voipio , Riku Voipio , "Franklin \\\"Snaipe\\\" Mathieu" , Laurent Vivier , 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 Reviewed-by: Laurent Vivier Message-Id: <20170217085800.28873-2-snaipe@diacritic.io> Signed-off-by: Laurent Vivier --- 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 2bba500..cec8428 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -11194,11 +11194,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.9.3