From: Wei Liu Subject: Re: [PATCH 3/9] libxl: poll: Avoid fd deregistration race POLLNVAL crash Date: Fri, 10 Jul 2015 11:41:02 +0100 Message-ID: <20150710104102.GK26853@zion.uk.xensource.com> References: <1436464077-2752-1-git-send-email-ian.jackson@eu.citrix.com> <1436464077-2752-4-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1436464077-2752-4-git-send-email-ian.jackson@eu.citrix.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: Ian Jackson Cc: Jim Fehlig , xen-devel@lists.xensource.com, Wei Liu , Ian Campbell List-Id: xen-devel@lists.xenproject.org On Thu, Jul 09, 2015 at 06:47:51PM +0100, Ian Jackson wrote: > 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 > Signed-off-by: Ian Jackson > CC: Jim Fehlig Acked-by: Wei Liu