postgresql/src/backend/libpq
Heikki Linnakangas 6b1b405ebf Fix snapshot reference leak if lo_export fails.
If lo_export() fails to open the target file or to write to it, it leaks
the created LargeObjectDesc and its snapshot in the top-transaction
context and resource owner. That's pretty harmless, it's a small leak
after all, but it gives the user a "Snapshot reference leak" warning.

Fix by using a short-lived memory context and no resource owner for
transient LargeObjectDescs that are opened and closed within one function
call. The leak is easiest to reproduce with lo_export() on a directory
that doesn't exist, but in principle the other lo_* functions could also
fail.

Backpatch to all supported versions.

Reported-by: Andrew B
Reviewed-by: Alvaro Herrera
Discussion: https://www.postgresql.org/message-id/32bf767a-2d65-71c4-f170-122f416bab7e@iki.fi
2021-11-03 10:52:38 +02:00
..
Makefile Refactor SASL code with a generic interface for its mechanisms 2021-07-07 10:55:15 +09:00
README.SSL Move EDH support to common files 2018-01-23 07:11:38 -05:00
auth-sasl.c Fix incorrect format placeholders 2021-09-08 08:57:05 +02:00
auth-scram.c Fix incorrect format placeholders 2021-09-08 08:57:05 +02:00
auth.c Message style improvements 2021-09-16 15:36:44 +02:00
be-fsstubs.c Fix snapshot reference leak if lo_export fails. 2021-11-03 10:52:38 +02:00
be-gssapi-common.c Don't assume GSSAPI result strings are null-terminated. 2021-06-23 14:01:32 -04:00
be-secure-common.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
be-secure-gssapi.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
be-secure-openssl.c Blind attempt to silence SSL compile failures on hamerkop. 2021-11-02 15:18:07 -04:00
be-secure.c Allow matching the DN of a client certificate for authentication 2021-03-29 15:49:39 -04:00
crypt.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
hba.c Fix RADIUS error reporting in hba file parsing 2021-05-31 18:43:48 +02:00
ifaddr.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
pg_hba.conf.sample pg_hba.conf.sample: Reword connection type section 2021-04-29 07:00:20 +02:00
pg_ident.conf.sample Reformat the comments in pg_hba.conf and pg_ident.conf 2010-01-26 06:58:39 +00:00
pqcomm.c Initial pgindent and pgperltidy run for v14. 2021-05-12 13:14:10 -04:00
pqformat.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
pqmq.c shm_mq: Update mq_bytes_written less often. 2021-10-14 16:13:36 -04:00
pqsignal.c Use signalfd(2) for epoll latches. 2021-03-01 14:12:02 +13:00

README.SSL

src/backend/libpq/README.SSL

SSL
===

>From the servers perspective:


  Receives StartupPacket
           |
           |
 (Is SSL_NEGOTIATE_CODE?) -----------  Normal startup
           |                  No
           |
           | Yes
           |
           |
 (Server compiled with USE_SSL?) ------- Send 'N'
           |                       No        |
           |                                 |
           | Yes                         Normal startup
           |
           |
        Send 'S'
           |
           |
      Establish SSL
           |
           |
      Normal startup





>From the clients perspective (v6.6 client _with_ SSL):


      Connect
         |
         |
  Send packet with SSL_NEGOTIATE_CODE
         |
         |
  Receive single char  ------- 'S' -------- Establish SSL
         |                                       |
         | '<else>'                              |
         |                                  Normal startup
         |
         |
   Is it 'E' for error  ------------------- Retry connection
         |                  Yes             without SSL
         | No
         |
   Is it 'N' for normal ------------------- Normal startup
         |                  Yes
         |
   Fail with unknown

---------------------------------------------------------------------------

Ephemeral DH
============

Since the server static private key ($DataDir/server.key) will
normally be stored unencrypted so that the database backend can
restart automatically, it is important that we select an algorithm
that continues to provide confidentiality even if the attacker has the
server's private key.  Ephemeral DH (EDH) keys provide this and more
(Perfect Forward Secrecy aka PFS).

N.B., the static private key should still be protected to the largest
extent possible, to minimize the risk of impersonations.

Another benefit of EDH is that it allows the backend and clients to
use DSA keys.  DSA keys can only provide digital signatures, not
encryption, and are often acceptable in jurisdictions where RSA keys
are unacceptable.

The downside to EDH is that it makes it impossible to use ssldump(1)
if there's a problem establishing an SSL session.  In this case you'll
need to temporarily disable EDH (see initialize_dh()).