]> xenbits.xensource.com Git - xen.git/commit
libxl: poll: Avoid fd deregistration race POLLNVAL crash
authorIan Jackson <ian.jackson@eu.citrix.com>
Wed, 12 Aug 2015 11:50:12 +0000 (12:50 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Wed, 12 Aug 2015 11:54:29 +0000 (12:54 +0100)
commit3bcb2c062a02e3c45d3f87478d2cbe1a134d395c
tree242e4b9e68a6617901579e63053d3bb3347be42c
parentf66f746df7983fac7f63b38b1b6bde11a791f1ed
libxl: poll: Avoid fd deregistration race POLLNVAL crash

It can happen that an fd is deregistered, and closed, and then a new
fd opened, and reregistered, all while another thread is in poll().

If this happens poll might report POLLNVAL, but the event loop would
think that the fd was supposed to have been valid, and then fail an
assertion:
  libxl_event.c:1183: afterpoll_check_fd: Assertion `poller->fds_changed || !(fds[slot].revents & 0x020)' failed.

We can't simply ignore POLLNVAL because if we have bugs which cause
messed-up fds, it is a serious problem which we really need to detect.

Instead, add extra tracking to spot when this possibility arises, and
abort on POLLNVAL if we are sure that it is unexpected.

Reported-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Jim Fehlig <jfehlig@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Tested-by: Jim Fehlig <jfehlig@suse.com>
(cherry picked from commit 681ce1681622a46d111cfdc4fc07e4cb565ae131)

(cherry picked from commit 7f7642f778b78e8e204fc082ce03072bb26887c7)

And, adjusted for semantic conflict over CTX vs ctx.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
(cherry picked from commit 3646b134c1673f09c0a239de10b0da4c9265c8e8)
Conflicts:
tools/libxl/libxl_event.c
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxl/libxl.c
tools/libxl/libxl_event.c
tools/libxl/libxl_internal.h