]> Git Repo - qemu.git/commitdiff
syscall: fixed mincore(2) not failing with ENOMEM
authorFranklin \"Snaipe\" Mathieu <[email protected]>
Fri, 17 Feb 2017 08:58:00 +0000 (08:58 +0000)
committerMichael Tokarev <[email protected]>
Tue, 28 Feb 2017 06:03:39 +0000 (09:03 +0300)
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 <[email protected]>
Cc: Riku Voipio <[email protected]>
Cc: Aurelien Jarno <[email protected]>
Reviewed-by: Laurent Vivier <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
linux-user/syscall.c

index f569f827fc2a418035d1d476061da7dbd3391723..6715ce38c44cc2eaa11b78298c331d9490292165 100644 (file)
@@ -11063,11 +11063,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:
This page took 0.040484 seconds and 4 git commands to generate.