From: Roger Pau Monne <roger.pau@citrix.com>
To: Ian Campbell <Ian.Campbell@citrix.com>
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>,
"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Subject: Re: [PATCH 1/2] libxl: fix reentrancy hazard in fd event processing
Date: Wed, 25 Jul 2012 17:49:42 +0100 [thread overview]
Message-ID: <501023A6.8050805@citrix.com> (raw)
In-Reply-To: <1343232346.18971.133.camel@zakaz.uk.xensource.com>
Ian Campbell wrote:
> On Fri, 2012-07-20 at 19:18 +0100, Ian Jackson wrote:
>> In afterpoll_internal, the callback functions may register and
>> deregister events arbitrarily. This means that we need to consider
>> the reentrancy-safety of the event machinery state variables.
>>
>> Most of the code is safe but the fd handling is not. Fix this by
>> arranging to restart the fd scan loop every time we call one of these
>> callback functions.
>>
>> For this loop to terminate, we modify afterpoll_check_fd so that it
>> returns only once for each of afterpoll's efds.
>>
>> Another possible solution would be simply to return from
>> afterpoll_internal after calling efd->func. That would be a small and
>> more obviously correct change but would prevent the process from
>> handling more than one fd event with a single call to poll.
>>
>> This is apropos of a report from Roger Pau Monne to me (pers.comm.)
>> of this crash on NetBSD:
>>
>> Program terminated with signal 11, Segmentation fault.
>> #0 0x00007f7ff743131b in afterpoll_check_fd (poller=<optimized out>, fds=0x7f7ff7b241c0, nfds=7, fd=-1, events=1)
>> at libxl_event.c:856
>> 856 if (fds[slot].fd != fd)
>
> Has Roger or you tested this now?
This works ok.
> It looks plausible to me.
>
>> diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
>> index 2781398..e938660 100644
>> --- a/tools/libxl/libxl_internal.h
>> +++ b/tools/libxl/libxl_internal.h
>> @@ -272,7 +272,7 @@ struct libxl__poller {
>> int fd_polls_allocd;
>>
>> int fd_rindices_allocd;
>> - int (*fd_rindices)[3]; /* see libxl_osevent_beforepoll */
>> + int (*fd_rindices)[3]; /* see libxl_event.c:beforepoll_internal */
>
> do you mean afterpoll here?
>
> Acked-by: Ian Campbell <ian.campbell@citrix.com>
>
>
next prev parent reply other threads:[~2012-07-25 16:49 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-20 18:18 [PATCH 0/2] libxl: event fixes for Roger Ian Jackson
2012-07-20 18:18 ` [PATCH 1/2] libxl: fix reentrancy hazard in fd event processing Ian Jackson
2012-07-25 16:05 ` Ian Campbell
2012-07-25 16:10 ` Ian Jackson
2012-07-25 16:33 ` Ian Campbell
2012-07-26 14:04 ` Ian Jackson
2012-07-26 16:23 ` Ian Campbell
2012-07-25 16:49 ` Roger Pau Monne [this message]
2012-07-20 18:18 ` [PATCH 2/2] libxl: do not blunder on if bootloader fails Ian Jackson
2012-07-23 11:09 ` Ian Campbell
2012-07-23 12:13 ` Ian Campbell
2012-07-20 18:22 ` [PATCH 0/2] libxl: event fixes for Roger Ian Jackson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=501023A6.8050805@citrix.com \
--to=roger.pau@citrix.com \
--cc=Ian.Campbell@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).