[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 05/13] linux-user: Translate flags argument to dup3 s
From: |
Laurent Vivier |
Subject: |
[Qemu-devel] [PULL 05/13] linux-user: Translate flags argument to dup3 syscall |
Date: |
Tue, 23 Jan 2018 15:47:59 +0100 |
From: Peter Maydell <address@hidden>
The third argument to dup3() is a flags word which may be
O_CLOEXEC. We weren't translating this flag from target to
host value, which meant that if the target used a different
value from the host (eg sparc guest and x86 host) the dup3()
call would fail EINVAL. Do the correct translation.
Fixes: https://bugs.launchpad.net/qemu/+bug/1704658
Reported-by: Bruno Haible <address@hidden>
Signed-off-by: Peter Maydell <address@hidden>
Reviewed-by: Laurent Vivier <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Laurent Vivier <address@hidden>
---
linux-user/syscall.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 39553c81b6..41ded90ee6 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8490,11 +8490,19 @@ abi_long do_syscall(void *cpu_env, int num, abi_long
arg1,
#endif
#if defined(CONFIG_DUP3) && defined(TARGET_NR_dup3)
case TARGET_NR_dup3:
- ret = get_errno(dup3(arg1, arg2, arg3));
+ {
+ int host_flags;
+
+ if ((arg3 & ~TARGET_O_CLOEXEC) != 0) {
+ return -EINVAL;
+ }
+ host_flags = target_to_host_bitmask(arg3, fcntl_flags_tbl);
+ ret = get_errno(dup3(arg1, arg2, host_flags));
if (ret >= 0) {
fd_trans_dup(arg1, arg2);
}
break;
+ }
#endif
#ifdef TARGET_NR_getppid /* not on alpha */
case TARGET_NR_getppid:
--
2.14.3
- [Qemu-devel] [PULL 00/13] Linux user for 2.12 patches, Laurent Vivier, 2018/01/23
- [Qemu-devel] [PULL 01/13] linux-user: Fix locking order in fork_start(), Laurent Vivier, 2018/01/23
- [Qemu-devel] [PULL 05/13] linux-user: Translate flags argument to dup3 syscall,
Laurent Vivier <=
- [Qemu-devel] [PULL 03/13] linux-user: Fix length calculations in host_to_target_cmsg(), Laurent Vivier, 2018/01/23
- [Qemu-devel] [PULL 08/13] linux-user: Add AT_SECURE auxval, Laurent Vivier, 2018/01/23
- [Qemu-devel] [PULL 09/13] linux-user: Add getcpu() support, Laurent Vivier, 2018/01/23
- [Qemu-devel] [PULL 10/13] linux-user: remove nmi.c and fw-path-provider.c, Laurent Vivier, 2018/01/23
- [Qemu-devel] [PULL 13/13] linux-user: implement renameat2, Laurent Vivier, 2018/01/23
- [Qemu-devel] [PULL 02/13] linux-user: wrap fork() in a start/end exclusive section, Laurent Vivier, 2018/01/23
- [Qemu-devel] [PULL 04/13] linux-user: Don't use CMSG_ALIGN(sizeof struct cmsghdr), Laurent Vivier, 2018/01/23