Daniel P. Berrangé <berra...@redhat.com> writes: > In previous commits > > eb3618e9 migration: activate TLS thread safety workaround > edea8183 io: add support for activating TLS thread safety workaround > 24ad5e19 crypto: implement workaround for GNUTLS thread safety problems > > an attempt was made to workaround broken gnutls thread safety when > TLS 1.3 rekeying is performed. > > Those patches acquired locks before calling gnutls_record_{send|recv} > but temporarily dropped the locks in the push/pull functions, in the > mistaken belief that there was a race inside gnutls that did not cross > execution of the push/pull functions. > > A non-deterministic reproducer mislead into thinking the workaround > was operating as expected, but this was wrong. Juraj demonstrated > that QEMU would still see errors from GNUTLS as well as crashes. > > The issue is that a pointer to internal state is saved before the > the push/pull functions are called, and after they return this > saved pointer is potentially invalid. IOW, it is never safe to > temporarily drop the mutexes inside the push/pull functions. The > lock must be held throughout execution of gnutls_record_{send|recv}. > > This would be possible with QEMU migration, except that the return > path thread sits in a blocking read waiting for data that very > rarely arrives from the destination QEMU. This blocks ability to > send any migration data in the other thread. > > It is possible to workaround this issue, however, by proactively > calling poll() to check for available incoming data before trying > the qio_channel_read() call. > > Reported-by: Juraj Marcin <jmar...@redhat.com> > Signed-off-by: Daniel P. Berrangé <berra...@redhat.com>
Reviewed-by: Fabiano Rosas <faro...@suse.de>