[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 14/14] syscall: fixed mincore(2) not failing with ENO
From: |
Michael Tokarev |
Subject: |
[Qemu-devel] [PULL 14/14] syscall: fixed mincore(2) not failing with ENOMEM |
Date: |
Tue, 28 Feb 2017 09:44:57 +0300 |
From: "Franklin \\\"Snaipe\\\" Mathieu" <address@hidden>
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 <address@hidden>
Cc: Riku Voipio <address@hidden>
Cc: Aurelien Jarno <address@hidden>
Reviewed-by: Laurent Vivier <address@hidden>
Signed-off-by: Michael Tokarev <address@hidden>
---
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 f569f82..6715ce3 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:
--
2.1.4
- [Qemu-devel] [PULL 00/14] Trivial patches for 2017-02-28, Michael Tokarev, 2017/02/28
- [Qemu-devel] [PULL 01/14] target/s390x: Fix typo, Michael Tokarev, 2017/02/28
- [Qemu-devel] [PULL 13/14] hw/acpi/tco.c: fix tco timer stop, Michael Tokarev, 2017/02/28
- [Qemu-devel] [PULL 06/14] ide: remove undefined behavior in ide-test, Michael Tokarev, 2017/02/28
- [Qemu-devel] [PULL 14/14] syscall: fixed mincore(2) not failing with ENOMEM,
Michael Tokarev <=
- [Qemu-devel] [PULL 05/14] CODING_STYLE: Mention preferred comment form, Michael Tokarev, 2017/02/28
- [Qemu-devel] [PULL 09/14] tests/prom-env: Enable the test for the sun4u machine, too, Michael Tokarev, 2017/02/28
- [Qemu-devel] [PULL 11/14] qemu-options.hx: add missing id=chr0 chardev argument in vhost-user example, Michael Tokarev, 2017/02/28
- [Qemu-devel] [PULL 10/14] Update copyright year, Michael Tokarev, 2017/02/28
- [Qemu-devel] [PULL 08/14] cadence_gem: Remove unused parameter debug message, Michael Tokarev, 2017/02/28
- [Qemu-devel] [PULL 04/14] hw/core/register: Mark the device with cannot_instantiate_with_device_add_yet, Michael Tokarev, 2017/02/28
- [Qemu-devel] [PULL 07/14] register: fix incorrect read mask, Michael Tokarev, 2017/02/28
- [Qemu-devel] [PULL 02/14] softfloat: Use correct type in float64_to_uint64_round_to_zero(), Michael Tokarev, 2017/02/28
- [Qemu-devel] [PULL 12/14] lm32: milkymist-tmu2: fix a third integer overflow, Michael Tokarev, 2017/02/28
- [Qemu-devel] [PULL 03/14] hw/core/or-irq: Mark the device with cannot_instantiate_with_device_add_yet, Michael Tokarev, 2017/02/28