On Mon, Jul 08, 2019 at 01:12:06PM +0200, Michal Privoznik wrote:
On 7/8/19 12:39 PM, Daniel P. Berrangé wrote:
> Neither the sasl_client_init or sasl_server_init methods are even
> remotely threadsafe. They do a bunch of one-time initialization and
> merely use a simple integer counter to avoid repeated work, not even
> using atomic increment/reads on the counter. This can easily race in a
> threaded program. Protect the calls using a virOnce initializer function
> which is guaranteed threadsafe at least from libvirt's POV.
>
> If the application using libvirt also uses another library that makes
> use of SASL then the race still exists. It is impossible to fix that
> fully except in SASL code itself.
>
> Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
> ---
> src/rpc/virnetsaslcontext.c | 50 ++++++++++++++++++++++++-------------
> 1 file changed, 33 insertions(+), 17 deletions(-)
Reviewed-by: Michal Privoznik <mprivozn(a)redhat.com>
Thanks Sahid for the report!
FYI i wrote a simple demo program that can reliably reproduce the problem
in isolation
Regards,
Daniel
--
|:
https://berrange.com -o-
https://www.flickr.com/photos/dberrange :|
|:
https://libvirt.org -o-
https://fstop138.berrange.com :|
|:
https://entangle-photo.org -o-
https://www.instagram.com/dberrange :|