diff options
author | Franklin \"Snaipe\" Mathieu <snaipe@diacritic.io> | 2017-02-17 08:58:00 +0000 |
---|---|---|
committer | Michael Tokarev <mjt@tls.msk.ru> | 2017-02-28 09:03:39 +0300 |
commit | f5507e0448bd34473af72509297617a783049024 (patch) | |
tree | 04280ed0fb5ac6b7dcc462b609908a56f0e42af8 | |
parent | 6c608953a5512b556fd0913d740e932366d6bb5d (diff) |
syscall: fixed mincore(2) not failing with ENOMEM
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 <snaipe@diacritic.io>
Cc: Riku Voipio <riku.voipio@linaro.org>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
-rw-r--r-- | linux-user/syscall.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f569f827fc..6715ce38c4 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -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: |