[Spice-devel] [PATCH 7/7] Avoids to initialise OpenSSL threading twice

Pavel Grunt pgrunt at redhat.com
Thu Aug 11 12:54:48 UTC 2016


On Thu, 2016-08-11 at 08:42 -0400, Frediano Ziglio wrote:
> > 
> > 
> > Hi Frediano,
> > 
> > did you notice any issues ?
> > 
> > CRYPTO_get_locking_callback is kinda deprecated/not needed/noop in recent
> > openssl:
> > https://github.com/openssl/openssl/commit/2e52e7df518d80188c865ea3f7bb3526d1
> > 4b0c
> > 08
> > 
> 
> Wonderful, finally some sane improvements about threading and library!
> This is really a good news!
> Hope they also fix the leaks one day of another.
> Didn't notice any issues, just preventing problems if another library
> linked to the same program decide the use the same functions.
> I think the patch is safe in any case.
yes, of course it is safe.
> As a future work we should detect OpenSSL version and avoid to
> initialize threads as useless.
I think it is worth adding a comment that is going to be fixed in openssl1.1

Pavel

> 
> Frediano
> 
> > 
> > Pavel
> > 
> > On Thu, 2016-08-11 at 09:50 +0100, Frediano Ziglio wrote:
> > > 
> > > Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> > > ---
> > >  server/reds.c | 7 +++++++
> > >  1 file changed, 7 insertions(+)
> > > 
> > > diff --git a/server/reds.c b/server/reds.c
> > > index 6f88649..f74c8d3 100644
> > > --- a/server/reds.c
> > > +++ b/server/reds.c
> > > @@ -2792,6 +2792,13 @@ static void openssl_thread_setup(void)
> > >  {
> > >      int i;
> > >  
> > > +    /* Somebody else already setup threading for OpenSSL,
> > > +     * don't do it twice to avoid possible races.
> > > +     */
> > > +    if (CRYPTO_get_locking_callback() != NULL) {
> > > +        return;
> > > +    }
> > > +
> > >      lock_cs = OPENSSL_malloc(CRYPTO_num_locks() *
> > >      sizeof(pthread_mutex_t));
> > >  
> > >      for (i = 0; i < CRYPTO_num_locks(); i++) {
> > 


More information about the Spice-devel mailing list