Bug 1072700 - _spice_timer_set truncates large "now" values
Summary: _spice_timer_set truncates large "now" values
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: spice-server
Version: 6.5
Hardware: Unspecified
OS: Unspecified
Target Milestone: rc
: ---
Assignee: Christophe Fergeau
QA Contact: Desktop QE
Depends On:
Blocks: 1227408
TreeView+ depends on / blocked
Reported: 2014-03-05 03:54 UTC by David Gibson
Modified: 2018-12-09 17:37 UTC (History)
9 users (show)

Fixed In Version: spice-server-0.12.4-9.el6
Doc Type: Bug Fix
Doc Text:
Cause: an integer overflow on a 32 bit timer value Consequence: infinite loop in spice-server on long running VMs (> 46 days) causing SPICE sessions to be unresponsive Fix: use 64 bit timer values where appropriate Result:
Clone Of:
: 1227408 (view as bug list)
Last Closed: 2014-10-14 05:04:48 UTC
Target Upstream Version:

Attachments (Terms of Use)
Tentative fix (1.92 KB, patch)
2014-03-05 04:30 UTC, David Gibson
no flags Details | Diff

System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 747853 0 None None None Never
Red Hat Product Errata RHBA-2014:1435 0 normal SHIPPED_LIVE spice-server bug fix update 2014-10-14 01:06:04 UTC

Description David Gibson 2014-03-05 03:54:04 UTC
Description of problem:

static void _spice_timer_set(SpiceTimer *timer, uint32_t ms, uint32_t now)

The _spice_timer_set() function takes a 32-bit integer for the "now" value.  The now value passed in however, can exceed 2^32 (it's in ms and derived from CLOCK_MONOTONIC, which will wrap around a 32-bit integer in around 46 days).

If the now value passed in exceeds 2^32, this will mean timers are inserted into the active list with expiry values before the current time, they will immediately trigger, and (if they don't make themselves inactive) be reinserted still before the current time.

This leads to an infinite loop in spice_timer_queue_cb().

Version-Release number of selected component (if applicable):

(but the same bug is in upstream git).

Comment 1 David Gibson 2014-03-05 04:30:22 UTC
Created attachment 870759 [details]
Tentative fix

Attaching a tentative fix for the bug.  This also adds some extra casts to make sure we can't truncate ime values in a few other places.

Comment 4 Marc-Andre Lureau 2014-03-07 12:57:23 UTC
patch looks good to me, moving to POST, to reflect that

Comment 5 Christophe Fergeau 2014-03-10 11:45:39 UTC
Sent upstream http://lists.freedesktop.org/archives/spice-devel/2014-March/016302.html

Comment 12 David Gibson 2014-04-02 04:58:46 UTC
Ok, I'm a bit baffled as to how the bug is not appearing under those conditions.

Do you have an active spice console to the VM?  Is it responding correctly?

Comment 13 Marian Krcmarik 2014-04-10 14:21:19 UTC
(In reply to David Gibson from comment #12)
> Ok, I'm a bit baffled as to how the bug is not appearing under those
> conditions.
> Do you have an active spice console to the VM?  Is it responding correctly?

Hm yes, I opened two spice consoles to the VMs which are running since January 31st and it seems to be fine, responsive and host seems to be fine as well. So we are not able to reproduce so I suggest sanityOnly Verification provided It solved customer problem.

Comment 14 David Gibson 2014-04-25 05:55:37 UTC
Ok, I'm really baffled as to how those systems can fail to show the bug.

Could you use gcore to grab a core from the running qemu processes on that high-uptime system so I can investigate what the triggering factor is?

Comment 18 Christophe Fergeau 2014-05-30 13:26:20 UTC
David, did you get a chance to look at Marian's core?

Comment 19 David Gibson 2014-06-02 02:52:44 UTC
Sorry, I've been busy.

I did take a look at the core, but it wasn't as useful as I hoped.  Without a running process, or a core at exactly the right moment, it's very difficult to tell why this bug isn't triggering.

I don't really have time to track this down more thoroughly, so I guess we'll just have to go with the sanity checking we've had.

Comment 22 errata-xmlrpc 2014-10-14 05:04:48 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


Note You need to log in before you can comment on or make changes to this bug.