cryptohash: missing locking functions for OpenSSL <= 1.0.2? - Mailing list pgsql-hackers

From Jacob Champion
Subject cryptohash: missing locking functions for OpenSSL <= 1.0.2?
Date
Msg-id fd3ba610085f1ff54623478cf2f7adf5af193cbb.camel@vmware.com
Whole thread Raw
Responses Re: cryptohash: missing locking functions for OpenSSL <= 1.0.2?  (Michael Paquier <michael@paquier.xyz>)
List pgsql-hackers
While reviewing the NSS patch [1], I noticed that the cryptohash
implementation for OpenSSL doesn't set up any locking callbacks in
frontend code. I think there has to be a call to
OPENSSL_set_locking_callback() before libpq starts reaching into the
EVP_* API, if ENABLE_THREAD_SAFETY and HAVE_CRYPTO_LOCK are both true.

This would only affect threaded libpq clients running OpenSSL 1.0.2 and
below, and it looks like the most likely code path to be affected is
the OpenSSL error stack. So if anything went wrong with one of those
hash calls, it's possible that libpq would crash (or worse, silently
misbehave somewhere in the TLS stack) instead of gracefully reporting
an error. [2] is an example of this in the wild.

--Jacob

[1] https://www.postgresql.org/message-id/40095f48c3c6d556293cb0ecf80ea10cdf7d26b3.camel%40vmware.com
[2] https://github.com/openssl/openssl/issues/4690

pgsql-hackers by date:

Previous
From: Cary Huang
Date:
Subject: Re: Fix typo about WalSndPrepareWrite
Next
From: Mark Dilger
Date:
Subject: Re: new heapcheck contrib module