diff options
author | Ian Jackson <ian.jackson@eu.citrix.com> | 2012-07-26 17:22:39 +0100 |
---|---|---|
committer | Ian Jackson <ian.jackson@eu.citrix.com> | 2012-07-26 17:22:39 +0100 |
commit | 60975d1b586acd4af34fb67ef20bd8cb3fde6153 (patch) | |
tree | 6f0842352ae345dfffc4498cddb3b3f4a4c1668e /tools/libxl/libxl_internal.h | |
parent | 09dc3b63b3edd989e7de6f7aaa2fa24f6996aab2 (diff) | |
download | xen-60975d1b586acd4af34fb67ef20bd8cb3fde6153.tar.gz xen-60975d1b586acd4af34fb67ef20bd8cb3fde6153.tar.bz2 xen-60975d1b586acd4af34fb67ef20bd8cb3fde6153.zip |
libxl: fix reentrancy hazard in fd event processing
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)
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Reported-by: Roger Pau Monne <roger.pau@citrix.com>
Tested-by: Roger Pau Monne <roger.pau@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
Diffstat (limited to 'tools/libxl/libxl_internal.h')
-rw-r--r-- | tools/libxl/libxl_internal.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index cfb35ab4a9..691b4f6705 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -276,7 +276,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 */ int wakeup_pipe[2]; /* 0 means no fd allocated */ }; |