]> git.proxmox.com Git - mirror_qemu.git/commitdiff
linux-user: Fix llseek with high bit of offset_low set
authorPeter Maydell <peter.maydell@linaro.org>
Thu, 11 Aug 2016 17:59:39 +0000 (18:59 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Tue, 16 Aug 2016 15:42:03 +0000 (16:42 +0100)
The llseek syscall takes two 32-bit arguments, offset_high
and offset_low, which must be combined to form a single
64-bit offset. Unfortunately we were combining them with
   (uint64_t)arg2 << 32) | arg3
and arg3 is a signed type; this meant that when promoting
arg3 to a 64-bit type it would be sign-extended. The effect
was that if the offset happened to have bit 31 set then
this bit would get sign-extended into all of bits 63..32.
Explicitly cast arg3 to abi_ulong to avoid the erroneous
sign extension.

Reported-by: Chanho Park <parkch98@gmail.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Tested-by: Chanho Park <parkch98@gmail.com>
Message-id: 1470938379-1133-1-git-send-email-peter.maydell@linaro.org

linux-user/syscall.c

index 7edfe4a228fa4e2b9415167d7ee07d1dc606671a..9facf7c3456574334225b55b1f307cf364cf32f9 100644 (file)
@@ -9389,7 +9389,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
         {
             int64_t res;
 #if !defined(__NR_llseek)
-            res = lseek(arg1, ((uint64_t)arg2 << 32) | arg3, arg5);
+            res = lseek(arg1, ((uint64_t)arg2 << 32) | (abi_ulong)arg3, arg5);
             if (res == -1) {
                 ret = get_errno(res);
             } else {