Skip to contentSkip to conversation

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

PATCH Applied Matus Kysel 2 participants 3 messages Sep 30, 2020 – Oct 26, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux-user: correct errno returned from accept4() syscall

accept4() returned wrong errno, that did not match current linux

---
 linux-user/syscall.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
linux-user/syscall.c +3 -3
index 897d20c076..5b8c20cf21 100644
@@ -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);
 
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw

Le 30/09/2020 à 17:16, Matus Kysel a écrit :

Quoted 22 lines

accept4() returned wrong errno, that did not match current linux

---
 linux-user/syscall.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
linux-user/syscall.c +2 -2
index 897d20c076..5b8c20cf21 100644
@@ -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;
 

linux-user/syscall.c static abi_long do_accept4(int fd, abi_ulong target_addr, · line 3506

Quoted 10 lines
linux-user/syscall.c +1 -1
     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 lore raw
In reply to Matus Kysel

Le 30/09/2020 à 17:16, Matus Kysel a écrit :

Quoted 22 lines

accept4() returned wrong errno, that did not match current linux

---
 linux-user/syscall.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
linux-user/syscall.c +2 -2
index 897d20c076..5b8c20cf21 100644
@@ -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;
 

linux-user/syscall.c static abi_long do_accept4(int fd, abi_ulong target_addr, · line 3506

Quoted 10 lines
linux-user/syscall.c +1 -1
     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