Don't crash if a connection closes early
Don't crash if a connection closes early

https://bugzilla.redhat.com/show_bug.cgi?id=1047577

When a client closes its connection to libvirtd early during
virConnectOpen, more specifically just after making
REMOTE_PROC_CONNECT_SUPPORTS_FEATURE call to check if
VIR_DRV_FEATURE_PROGRAM_KEEPALIVE is supported without even waiting for
the result, libvirtd may crash due to a race in keep-alive
initialization. Once receiving the REMOTE_PROC_CONNECT_SUPPORTS_FEATURE
call, the daemon's event loop delegates it to a worker thread. In case
the event loop detects EOF on the connection and calls
virNetServerClientClose before the worker thread starts to handle
REMOTE_PROC_CONNECT_SUPPORTS_FEATURE call, client->keepalive will be
disposed by the time virNetServerClientStartKeepAlive gets called from
remoteDispatchConnectSupportsFeature. Because the flow is common for
both authenticated and read-only connections, even unprivileged clients
may cause the daemon to crash.

To avoid the crash, virNetServerClientStartKeepAlive needs to check if
the connection is still open before starting keep-alive protocol.

Every libvirt release since 0.9.8 is affected by this bug.

rlaager/libvirt,rlaager/libvirt,andreabolognani/libvirt,elmarco/libvirt,olafhering/libvirt,VenkatDatta/libvirt,crobinso/libvirt,libvirt/libvirt,zippy2/libvirt,libvirt/libvirt,shugaoye/libvirt,crobinso/libvirt,VenkatDatta/libvirt,shugaoye/libvirt,agx/libvirt,eskultety/libvirt,datto/libvirt,jardasgit/libvirt,shugaoye/libvirt,rlaager/libvirt,VenkatDatta/libvirt,elmarco/libvirt,taget/libvirt,taget/libvirt,eskultety/libvirt,agx/libvirt,eskultety/libvirt,taget/libvirt,agx/libvirt,VenkatDatta/libvirt,elmarco/libvirt,zippy2/libvirt,fabianfreyer/libvirt,nertpinx/libvirt,fabianfreyer/libvirt,fabianfreyer/libvirt,libvirt/libvirt,jfehlig/libvirt,eskultety/libvirt,nertpinx/libvirt,datto/libvirt,agx/libvirt,jardasgit/libvirt,jfehlig/libvirt,VenkatDatta/libvirt,jardasgit/libvirt,crobinso/libvirt,andreabolognani/libvirt,elmarco/libvirt,jardasgit/libvirt,datto/libvirt,rlaager/libvirt,andreabolognani/libvirt,fabianfreyer/libvirt,jfehlig/libvirt,nertpinx/libvirt,zippy2/libvirt,eskultety/libvirt,olafhering/libvirt,shugaoye/libvirt,olafhering/libvirt,crobinso/libvirt,datto/libvirt,jardasgit/libvirt,andreabolognani/libvirt,fabianfreyer/libvirt,olafhering/libvirt,agx/libvirt,nertpinx/libvirt,nertpinx/libvirt,datto/libvirt,shugaoye/libvirt,taget/libvirt,jfehlig/libvirt,elmarco/libvirt,andreabolognani/libvirt,rlaager/libvirt,taget/libvirt,libvirt/libvirt,zippy2/libvirt