From: Ian Jackson Subject: Re: [PATCH 2/2] libxl: fix stale timeout event callback race Date: Wed, 12 Dec 2012 17:37:51 +0000 Message-ID: <20680.49391.646654.814456@mariner.uk.xensource.com> References: <20678.5159.946248.90947@mariner.uk.xensource.com> <1355158624-11163-2-git-send-email-ian.jackson@eu.citrix.com> <50C7B974.4050706@suse.com> <20680.47971.962603.851882@mariner.uk.xensource.com> <50C8BE3F.4040402@suse.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <50C8BE3F.4040402@suse.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jim Fehlig Cc: "xen-devel@lists.xen.org" , Ian Campbell , Bamvor Jian Zhang List-Id: xen-devel@lists.xenproject.org Jim Fehlig writes ("Re: [Xen-devel] [PATCH 2/2] libxl: fix stale timeout event callback race"): > Ian Jackson wrote: > > Specifically, this code has an integer arithmetic overflow. > > Well, this patch is removing that buggy code :). I think you need to have some code somewhere which does the complicated arithmetic dance to avoid the integer overflow. Does your timer registration function have the same bug ? > After again reading > libxl_event.h, I'm considering the below patch in the libvirt libxl > driver. The change is primarily inspired by this comment for > libxl_osevent_occurred_timeout: ... > /* Implicitly, on entry to this function the timeout has been > * deregistered. If _occurred_timeout is called, libxl will not > * call timeout_deregister; if it wants to requeue the timeout it > * will call timeout_register again. > */ Well your patch is only correct when used with the new libxl, with my patches. > diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c > index 302f81c..d4055be 100644 > --- a/src/libxl/libxl_driver.c > +++ b/src/libxl/libxl_driver.c > @@ -184,6 +184,8 @@ static void libxlTimerCallback(int timer > ATTRIBUTE_UNUSED, void *timer_v) > { > struct libxlOSEventHookTimerInfo *timer_info = timer_v; > > + virEventRemoveTimeout(timer_info->id); > + timer_info->id = -1; I don't understand why you need this. Doesn't libvirt remove timers when they fire ? If it doesn't, do they otherwise not keep reoccurring ? Ian.