[PATCH] linux-user: correct errno returned from accept4() syscall

Matus Kysel posted 1 patch 3 years, 7 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20200930151616.3588165-1-mkysel@tachyum.com
Test docker-quick@centos7 failed
Test docker-mingw@fedora failed
Test checkpatch failed
Test FreeBSD failed
Maintainers: Laurent Vivier <laurent@vivier.eu>
linux-user/syscall.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
[PATCH] linux-user: correct errno returned from accept4() syscall
Posted by Matus Kysel 3 years, 7 months ago
accept4() returned wrong errno, that did not match current linux

Signed-off-by: Matus Kysel <mkysel@tachyum.com>
---
 linux-user/syscall.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 897d20c076..5b8c20cf21 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -3491,16 +3491,16 @@ static abi_long do_accept4(int fd, abi_ulong target_addr,
         return get_errno(safe_accept4(fd, NULL, NULL, host_flags));
     }
 
-    /* linux returns EINVAL if addrlen pointer is invalid */
+    /* linux returns EFAULT if addrlen pointer is invalid */
     if (get_user_u32(addrlen, target_addrlen_addr))
-        return -TARGET_EINVAL;
+        return -TARGET_EFAULT;
 
     if ((int)addrlen < 0) {
         return -TARGET_EINVAL;
     }
 
     if (!access_ok(VERIFY_WRITE, target_addr, addrlen))
-        return -TARGET_EINVAL;
+        return -TARGET_EFAULT;
 
     addr = alloca(addrlen);
 
-- 
2.25.1


Re: [PATCH] linux-user: correct errno returned from accept4() syscall
Posted by Laurent Vivier 3 years, 7 months ago
Le 30/09/2020 à 17:16, Matus Kysel a écrit :
> accept4() returned wrong errno, that did not match current linux
> 
> Signed-off-by: Matus Kysel <mkysel@tachyum.com>
> ---
>  linux-user/syscall.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 897d20c076..5b8c20cf21 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -3491,16 +3491,16 @@ static abi_long do_accept4(int fd, abi_ulong target_addr,
>          return get_errno(safe_accept4(fd, NULL, NULL, host_flags));
>      }
>  
> -    /* linux returns EINVAL if addrlen pointer is invalid */
> +    /* linux returns EFAULT if addrlen pointer is invalid */
>      if (get_user_u32(addrlen, target_addrlen_addr))
> -        return -TARGET_EINVAL;
> +        return -TARGET_EFAULT;
>  
>      if ((int)addrlen < 0) {
>          return -TARGET_EINVAL;
>      }
>  
>      if (!access_ok(VERIFY_WRITE, target_addr, addrlen))
> -        return -TARGET_EINVAL;
> +        return -TARGET_EFAULT;
>  
>      addr = alloca(addrlen);
>  
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>

Re: [PATCH] linux-user: correct errno returned from accept4() syscall
Posted by Laurent Vivier 3 years, 6 months ago
Le 30/09/2020 à 17:16, Matus Kysel a écrit :
> accept4() returned wrong errno, that did not match current linux
> 
> Signed-off-by: Matus Kysel <mkysel@tachyum.com>
> ---
>  linux-user/syscall.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 897d20c076..5b8c20cf21 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -3491,16 +3491,16 @@ static abi_long do_accept4(int fd, abi_ulong target_addr,
>          return get_errno(safe_accept4(fd, NULL, NULL, host_flags));
>      }
>  
> -    /* linux returns EINVAL if addrlen pointer is invalid */
> +    /* linux returns EFAULT if addrlen pointer is invalid */
>      if (get_user_u32(addrlen, target_addrlen_addr))
> -        return -TARGET_EINVAL;
> +        return -TARGET_EFAULT;
>  
>      if ((int)addrlen < 0) {
>          return -TARGET_EINVAL;
>      }
>  
>      if (!access_ok(VERIFY_WRITE, target_addr, addrlen))
> -        return -TARGET_EINVAL;
> +        return -TARGET_EFAULT;
>  
>      addr = alloca(addrlen);
>  
> 

Applied to my linux-user-for-5.2 branch.

Thanks,
Laurent