From mboxrd@z Thu Jan 1 00:00:00 1970 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 From: Laurent Vivier Date: Mon, 27 Feb 2017 23:33:37 +0100 Message-Id: <20170227223337.17434-7-laurent@vivier.eu> In-Reply-To: <20170227223337.17434-1-laurent@vivier.eu> References: <20170227223337.17434-1-laurent@vivier.eu> Subject: [Qemu-devel] [PULL 6/6] syscall: fixed mincore(2) not failing with ENOMEM List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Riku Voipio , "Franklin \\\"Snaipe\\\" Mathieu" , Riku Voipio , Aurelien Jarno , Laurent Vivier 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: -- 2.9.3