qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH for-2.2] qemu-timer: Avoid overflows when conver


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH for-2.2] qemu-timer: Avoid overflows when converting timeout to struct timespec
Date: Thu, 27 Nov 2014 11:33:24 +0000

On 26 November 2014 at 03:09, Fam Zheng <address@hidden> wrote:
> On Tue, 11/25 18:21, Peter Maydell wrote:
>> In qemu_poll_ns(), when we convert an int64_t nanosecond timeout into
>> a struct timespec, we may accidentally run into overflow problems if
>> the timeout is very long. This happens because the tv_sec field is a
>> time_t, which is signed, so we might end up setting it to a negative
>> value by mistake. This will result in what was intended to be a
>> near-infinite timeout turning into an instantaneous timeout, and we'll
>> busy loop. Cap the maximum timeout at INT32_MAX seconds (about 68 years)
>> to avoid this problem.

> Reviewed-by: Fam Zheng <address@hidden>

Thanks. Applied to master (with a cc:stable).

-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]