postgresql/src
Michael Paquier 01eca6a913 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 8bb14cdd33, 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
2023-11-27 09:40:44 +09:00
..
backend Display length and bounds histograms in pg_stats 2023-11-27 01:32:17 +02:00
bin C comment: add header to pg_test_fsync.c 2023-11-25 11:04:46 -05:00
common Make ResourceOwners more easily extensible. 2023-11-08 13:30:50 +02:00
fe_utils Remove unneeded assignments in for loop header 2023-11-21 16:10:27 +01:00
include Display length and bounds histograms in pg_stats 2023-11-27 01:32:17 +02:00
interfaces Fix race condition with BIO methods initialization in libpq with threads 2023-11-27 09:40:44 +09:00
makefiles Remove distprep 2023-11-06 15:18:04 +01:00
pl Don't specify number of dimensions in cases where we don't know it. 2023-11-17 11:29:46 -05:00
port Fix whitespace. 2023-11-25 10:43:39 +13:00
template Use unnamed POSIX semaphores on Cygwin. 2023-01-06 10:33:28 +13:00
test Display length and bounds histograms in pg_stats 2023-11-27 01:32:17 +02:00
timezone Remove distprep 2023-11-06 15:18:04 +01:00
tools Fix brin.c indentation issues introduced by c1ec02be1d 2023-11-26 21:35:32 +01:00
tutorial Pre-beta mechanical code beautification. 2023-05-19 17:24:48 -04:00
.gitignore
DEVELOPERS
Makefile Remove distprep 2023-11-06 15:18:04 +01:00
Makefile.global.in Remove distprep 2023-11-06 15:18:04 +01:00
Makefile.shlib Stop using "-multiply_defined suppress" on macOS. 2023-09-26 21:06:21 -04:00
meson.build Integrate pg_bsd_indent into our build/test infrastructure. 2023-02-12 12:22:21 -05:00
nls-global.mk Remove distprep 2023-11-06 15:18:04 +01:00