summaryrefslogtreecommitdiffstats
path: root/linux-user/syscall.c
diff options
context:
space:
mode:
authorLaurent Vivier2020-08-27 09:04:49 +0200
committerLaurent Vivier2020-08-27 12:29:50 +0200
commit00576757893aa63d221418a1d05c08ed10f94c09 (patch)
tree35cf2c5503ead73443976fc3eefee9c706b70fd7 /linux-user/syscall.c
parentlinux-user: Fix 'mq_timedsend()' and 'mq_timedreceive()' (diff)
downloadqemu-00576757893aa63d221418a1d05c08ed10f94c09.tar.gz
qemu-00576757893aa63d221418a1d05c08ed10f94c09.tar.xz
qemu-00576757893aa63d221418a1d05c08ed10f94c09.zip
linux-user: fix target_to_host_timespec64()
in 32 bit mode, drop the padding in tv_nsec. If host is 64bit and target is 32bit, the padding bytes will be copied from the target and as the kernel checks the value, the syscall exits with EINVAL. Signed-off-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20200827070449.2386007-1-laurent@vivier.eu> Fixes: c6c8d1026e75 ("linux-user/syscall: Add support for clock_gettime64/clock_settime64")
Diffstat (limited to 'linux-user/syscall.c')
-rw-r--r--linux-user/syscall.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index fd13e72305..3b725bbe25 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1229,6 +1229,8 @@ static inline abi_long target_to_host_timespec64(struct timespec *host_ts,
}
__get_user(host_ts->tv_sec, &target_ts->tv_sec);
__get_user(host_ts->tv_nsec, &target_ts->tv_nsec);
+ /* in 32bit mode, this drops the padding */
+ host_ts->tv_nsec = (long)(abi_long)host_ts->tv_nsec;
unlock_user_struct(target_ts, target_addr, 0);
return 0;
}