* [Qemu-devel] [PATCH for-2.7] linux-user: Fix llseek with high bit of offset_low set
@ 2016-08-11 17:59 Peter Maydell
2016-08-15 13:41 ` Chanho Park
0 siblings, 1 reply; 4+ messages in thread
From: Peter Maydell @ 2016-08-11 17:59 UTC (permalink / raw)
To: qemu-devel; +Cc: patches, Riku Voipio, Chanho Park
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>
---
Long-standing bug and we're quite close to 2.7 but the
fix is trivial so if somebody would like to review it
I think we could put it in...
linux-user/syscall.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index ebdb753..b4e21d3 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -9406,7 +9406,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 {
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH for-2.7] linux-user: Fix llseek with high bit of offset_low set
2016-08-11 17:59 [Qemu-devel] [PATCH for-2.7] linux-user: Fix llseek with high bit of offset_low set Peter Maydell
@ 2016-08-15 13:41 ` Chanho Park
2016-08-16 13:44 ` Riku Voipio
0 siblings, 1 reply; 4+ messages in thread
From: Chanho Park @ 2016-08-15 13:41 UTC (permalink / raw)
To: Peter Maydell; +Cc: QEMU Developers, patches, Riku Voipio
It works perfectly.
Thanks.
Tested-by: Chanho Park <parkch98@gmail.com>
On Fri, Aug 12, 2016 at 2:59 AM, Peter Maydell <peter.maydell@linaro.org> wrote:
> 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>
> ---
> Long-standing bug and we're quite close to 2.7 but the
> fix is trivial so if somebody would like to review it
> I think we could put it in...
>
> linux-user/syscall.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index ebdb753..b4e21d3 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -9406,7 +9406,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 {
> --
> 2.7.4
>
--
Best Regards,
Chanho Park
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH for-2.7] linux-user: Fix llseek with high bit of offset_low set
2016-08-15 13:41 ` Chanho Park
@ 2016-08-16 13:44 ` Riku Voipio
2016-08-16 16:10 ` Peter Maydell
0 siblings, 1 reply; 4+ messages in thread
From: Riku Voipio @ 2016-08-16 13:44 UTC (permalink / raw)
To: Chanho Park; +Cc: Peter Maydell, QEMU Developers, patches
Hi,
applied to linux-user-for upstream.
Riku
On Mon, Aug 15, 2016 at 10:41:35PM +0900, Chanho Park wrote:
> It works perfectly.
> Thanks.
>
> Tested-by: Chanho Park <parkch98@gmail.com>
>
> On Fri, Aug 12, 2016 at 2:59 AM, Peter Maydell <peter.maydell@linaro.org> wrote:
> > 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>
> > ---
> > Long-standing bug and we're quite close to 2.7 but the
> > fix is trivial so if somebody would like to review it
> > I think we could put it in...
> >
> > linux-user/syscall.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> > index ebdb753..b4e21d3 100644
> > --- a/linux-user/syscall.c
> > +++ b/linux-user/syscall.c
> > @@ -9406,7 +9406,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 {
> > --
> > 2.7.4
> >
>
>
>
> --
> Best Regards,
> Chanho Park
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH for-2.7] linux-user: Fix llseek with high bit of offset_low set
2016-08-16 13:44 ` Riku Voipio
@ 2016-08-16 16:10 ` Peter Maydell
0 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2016-08-16 16:10 UTC (permalink / raw)
To: Riku Voipio; +Cc: Chanho Park, QEMU Developers, Patch Tracking
On 16 August 2016 at 14:44, Riku Voipio <riku.voipio@iki.fi> wrote:
> Hi,
>
> applied to linux-user-for upstream.
Applied to master, thanks.
-- PMM
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-08-16 16:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-11 17:59 [Qemu-devel] [PATCH for-2.7] linux-user: Fix llseek with high bit of offset_low set Peter Maydell
2016-08-15 13:41 ` Chanho Park
2016-08-16 13:44 ` Riku Voipio
2016-08-16 16:10 ` Peter Maydell
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.