- Notifications
You must be signed in to change notification settings - Fork5
Commitb37c90f
committed
Fix SSL deadlock risk in libpq
In libpq, we set up and pass to OpenSSL callback routines to handlelocking. When we run out of SSL connections, we try to clean thingsup by de-registering the hooks. Unfortunately, we had a few callsinto the OpenSSL library after these hooks were de-registered duringSSL cleanup which lead to deadlocking. This moves the thread callbackcleanup to be after all SSL-cleanup related OpenSSL library calls.I've been unable to reproduce the deadlock with this fix.In passing, also move the close_SSL call to be after unlocking ourssl_config mutex when in a failure state. While it looks prettyunlikely to be an issue, it could have resulted in deadlocks if weended up in this code path due to something other than SSL_newfailing. Thanks to Heikki for pointing this out.Back-patch to all supported versions; note that the close_SSL issueonly goes back to 9.0, so that hunk isn't included in the 8.4 patch.Initially found and reported by Vesa-Matti J Kari; many thanks toboth Heikki and Andres for their help running down the specificissue and reviewing the patch.1 parentb882246 commitb37c90f
1 file changed
+22
-2
lines changedLines changed: 22 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
282 | 282 |
| |
283 | 283 |
| |
284 | 284 |
| |
285 |
| - | |
286 | 285 |
| |
287 | 286 |
| |
288 | 287 |
| |
| 288 | + | |
| 289 | + | |
289 | 290 |
| |
290 | 291 |
| |
291 | 292 |
| |
| |||
1537 | 1538 |
| |
1538 | 1539 |
| |
1539 | 1540 |
| |
| 1541 | + | |
| 1542 | + | |
1540 | 1543 |
| |
1541 | 1544 |
| |
1542 | 1545 |
| |
1543 | 1546 |
| |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
1544 | 1554 |
| |
1545 | 1555 |
| |
1546 | 1556 |
| |
1547 | 1557 |
| |
1548 |
| - | |
1549 | 1558 |
| |
1550 | 1559 |
| |
1551 | 1560 |
| |
| |||
1565 | 1574 |
| |
1566 | 1575 |
| |
1567 | 1576 |
| |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
1568 | 1588 |
| |
1569 | 1589 |
| |
1570 | 1590 |
| |
|
0 commit comments
Comments
(0)