pgsql: Fix race condition with BIO methods initialization in libpq with

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема pgsql: Fix race condition with BIO methods initialization in libpq with
Дата
Msg-id E1r7Pgb-007QLu-Oc@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix race condition with BIO methods initialization in libpq with threads

The libpq code in charge of creating per-connection SSL objects was
prone to a race condition when loading the custom BIO methods needed by
my_SSL_set_fd().  As BIO methods are stored as a static variable, the
initialization of a connection could fail because it could be possible
to have one thread refer to my_bio_methods while it is being manipulated
by a second concurrent thread.

This error has been introduced by 8bb14cdd33de, that has removed
ssl_config_mutex around the call of my_SSL_set_fd(), that itself sets
the custom BIO methods used in libpq.  Like previously, the BIO method
initialization is now protected by the existing ssl_config_mutex, itself
initialized earlier for WIN32.

While on it, document that my_bio_methods is protected by
ssl_config_mutex, as this can be easy to miss.

Reported-by: Willi Mann
Author: Willi Mann, Michael Paquier
Discussion: https://postgr.es/m/e77abc4c-4d03-4058-a9d7-ef0035657e04@celonis.com
Backpatch-through: 12

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/0217a7444a5760e5f0bb2d5e4d4b17d81ae438a0

Modified Files
--------------
src/interfaces/libpq/fe-secure-openssl.c | 73 ++++++++++++++++++++++----------
1 file changed, 51 insertions(+), 22 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Alexander Korotkov
Дата:
Сообщение: pgsql: Display length and bounds histograms in pg_stats
Следующее
От: Alexander Korotkov
Дата:
Сообщение: pgsql: Track statement entry timestamp in contrib/pg_stat_statements