cryptohash: missing locking functions for OpenSSL <= 1.0.2?

From: Jacob Champion <pchampion(at)vmware(dot)com>
To: "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: cryptohash: missing locking functions for OpenSSL <= 1.0.2?
Date: 2021-02-17 18:34:36
Message-ID: fd3ba610085f1ff54623478cf2f7adf5af193cbb.camel@vmware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Mark Dilger 2021-02-17 18:46:10 Re: new heapcheck contrib module
Previous Message Cary Huang 2021-02-17 18:13:57 Re: Fix typo about WalSndPrepareWrite