[Top][All Lists]

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

[Qemu-commits] [qemu/qemu] 490309: qemu-timer: Avoid overflows when conv

From: GitHub
Subject: [Qemu-commits] [qemu/qemu] 490309: qemu-timer: Avoid overflows when converting timeou...
Date: Thu, 27 Nov 2014 04:00:06 -0800

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: 490309fcfbed9fa1ed357541f609975016a34628
  Author: Peter Maydell <address@hidden>
  Date:   2014-11-27 (Thu, 27 Nov 2014)

  Changed paths:
    M qemu-timer.c

  Log Message:
  qemu-timer: Avoid overflows when converting timeout to struct timespec

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.

This specifically manifested on ARM hosts as an extreme slowdown on
guest shutdown (when the guest reprogrammed the PL031 RTC to not
generate alarms using a very long timeout) but could happen on other
hosts and guests too.

Reported-by: Christoffer Dall <address@hidden>
Cc: address@hidden
Signed-off-by: Peter Maydell <address@hidden>
Reviewed-by: Fam Zheng <address@hidden>
Message-id: address@hidden

reply via email to

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