Bug 1072700

Summary: _spice_timer_set truncates large "now" values
Product: Red Hat Enterprise Linux 6 Reporter: David Gibson <dgibson>
Component: spice-serverAssignee: Christophe Fergeau <cfergeau>
Status: CLOSED ERRATA QA Contact: Desktop QE <desktop-qa-list>
Severity: high Docs Contact:
Priority: high    
Version: 6.5CC: cfergeau, dblechte, dgibson, ederevea, marcandre.lureau, mkenneth, mkrcmari, rbalakri, tlavigne
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
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:
Story Points: ---
Clone Of:
: 1227408 (view as bug list) Environment:
Last Closed: 2014-10-14 05:04:48 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1227408    
Attachments:
Description Flags
Tentative fix none

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):

spice-server-0.12.4-6.el6.x86_64
(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.

http://rhn.redhat.com/errata/RHBA-2014-1435.html