From patchwork Mon Feb 27 22:33:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 733195 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 3vXGvd4vSzz9s8D for ; Tue, 28 Feb 2017 09:43:24 +1100 (AEDT) Received: from localhost ([::1]:57348 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciU0n-0000p8-MQ for incoming@patchwork.ozlabs.org; Mon, 27 Feb 2017 17:43:21 -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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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_long arg1, case TARGET_NR_mincore: { void *a; + ret = -TARGET_ENOMEM; + a = lock_user(VERIFY_READ, arg1, arg2, 0); + if (!a) { + goto fail; + } ret = -TARGET_EFAULT; - if (!(a = lock_user(VERIFY_READ, arg1,arg2, 0))) - goto efault; - if (!(p = lock_user_string(arg3))) + p = lock_user_string(arg3); + if (!p) { goto mincore_fail; + } ret = get_errno(mincore(a, arg2, p)); unlock_user(p, arg3, ret); mincore_fail: