qemu-trivial
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-trivial] [Qemu-devel] [PATCH v2] syscall: fixed mincore(2) not


From: Laurent Vivier
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH v2] syscall: fixed mincore(2) not failing with ENOMEM
Date: Sun, 26 Feb 2017 14:12:39 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0

Le 17/02/2017 à 09:58, Franklin Snaipe Mathieu a écrit :
> 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>
> ---
>  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 9be8e9530e..733e0009e1 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -11061,11 +11061,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:
> 

Reviewed-by: Laurent Vivier <address@hidden>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]