Skip to contentSkip to conversation

linux-user: pass correct host flags to accept4()

PATCH Applied Petar Jovanovic 3 participants 3 messages Mar 31, 2014 – Apr 1, 2014

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 linux-user: pass correct host flags to accept4()

From: Petar Jovanovic <[email protected]>

Flags NONBLOCK and CLOEXEC can have different values on the host and the guest, so set correct host values before calling accept4().

This fixes several issues with accept4 system call and user-mode of QEMU.

---

v2:
- use target_to_host_bitmask() (per comment from Peter Maydell)

 linux-user/syscall.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
linux-user/syscall.c +5 -2
index 2eac6d5..9864813 100644
@@ -2062,9 +2062,12 @@ static abi_long do_accept4(int fd, abi_ulong target_addr,
     socklen_t addrlen;
     void *addr;
     abi_long ret;
+    int host_flags;
+
+    host_flags = target_to_host_bitmask(flags, fcntl_flags_tbl);
 
     if (target_addr == 0) {
-        return get_errno(accept4(fd, NULL, NULL, flags));
+        return get_errno(accept4(fd, NULL, NULL, host_flags));
     }
 
     /* linux returns EINVAL if addrlen pointer is invalid */
@@ -2080,7 +2083,7 @@ static abi_long do_accept4(int fd, abi_ulong target_addr,
 
     addr = alloca(addrlen);
 
-    ret = get_errno(accept4(fd, addr, &addrlen, flags));
+    ret = get_errno(accept4(fd, addr, &addrlen, host_flags));
     if (!is_error(ret)) {
         host_to_target_sockaddr(target_addr, addr, addrlen);
         if (put_user_u32(addrlen, target_addrlen_addr))
Signature · 1 line
1.7.9.5
Applied
#2 lore raw

Hi,

Applied to my for-2.0 branch,

Thanks

Quoted 15 lines · Peter Maydell
Quoted 8 lines · Petar Jovanovic

From: Petar Jovanovic <[email protected]>

Flags NONBLOCK and CLOEXEC can have different values on the host and the guest, so set correct host values before calling accept4().

This fixes several issues with accept4 system call and user-mode of QEMU.

thanks
-- PMM