]> git.ipfire.org Git - thirdparty/libvirt.git/commit
rpc: fix race sending and encoding sasl data
authorDaniel P. Berrange <berrange@redhat.com>
Mon, 18 Dec 2017 17:41:12 +0000 (17:41 +0000)
committerDaniel P. Berrangé <berrange@redhat.com>
Thu, 25 Jan 2018 16:29:24 +0000 (16:29 +0000)
commit4e13fb02fee634931781e4cf77142acf68a69e55
tree7cf700894c0bd22a6fa2695f65c46749baa58963
parent0c710a37ea265dc7dfa0ebcebf1e21e4c6b2ea21
rpc: fix race sending and encoding sasl data

The virNetSocketWriteSASL method has to encode the buffer it is given and then
write it to the underlying socket. This write is not guaranteed to send the
full amount of data that was encoded by SASL. We cache the SASL encoded data so
that on the next invocation of virNetSocketWriteSASL we carry on sending it.

The subtle problem is that the 'len' value passed into virNetSocketWriteSASL on
the 2nd call may be larger than the original value. So when we've completed
sending the SASL encoded data we previously cached, we must return the original
length we encoded, not the new length.

This flaw means we could potentially have been discarded queued data without
sending it. This would have exhibited itself as a libvirt client never receiving
the reply to a method it invokes, async events silently going missing, or worse
stream data silently getting dropped.

For this to be a problem libvirtd would have to be queued data to send to the
client, while at the same time the TCP socket send buffer is full (due to a very
slow client). This is quite unlikely so if this bug was ever triggered by a real
world user it would be almost impossible to reproduce or diagnose, if indeed it
was ever noticed at all.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
src/rpc/virnetsocket.c