[libvirt] [PATCH] rpc: ensure thread safe initialization of SASL library
Michal Privoznik
mprivozn at redhat.com
Mon Jul 8 11:12:06 UTC 2019
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 at redhat.com>
> ---
> src/rpc/virnetsaslcontext.c | 50 ++++++++++++++++++++++++-------------
> 1 file changed, 33 insertions(+), 17 deletions(-)
Reviewed-by: Michal Privoznik <mprivozn at redhat.com>
Thanks Sahid for the report!
Michal
More information about the libvir-list
mailing list