pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Avoid corner-case memory leak in SSL parameter processing.
5+ messages / 1 participants
[nested] [flat]

* pgsql: Avoid corner-case memory leak in SSL parameter processing.
@ 2021-03-16 20:03 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2021-03-16 20:03 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Avoid corner-case memory leak in SSL parameter processing.

After reading the root cert list from the ssl_ca_file, immediately
install it as client CA list of the new SSL context.  That gives the
SSL context ownership of the list, so that SSL_CTX_free will free it.
This avoids a permanent memory leak if we fail further down in
be_tls_init(), which could happen if bogus CRL data is offered.

The leak could only amount to something if the CRL parameters get
broken after server start (else we'd just quit) and then the server
is SIGHUP'd many times without fixing the CRL data.  That's rather
unlikely perhaps, but it seems worth fixing, if only because the
code is clearer this way.

While we're here, add some comments about the memory management
aspects of this logic.

Noted by Jelte Fennema and independently by Andres Freund.
Back-patch to v10; before commit de41869b6 it doesn't matter,
since we'd not re-execute this code during SIGHUP.

Discussion: https://postgr.es/m/16160-18367e56e9a28264@postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/4b12ab18c9d0735d760bf7667b158707b06e5df8

Modified Files
--------------
src/backend/libpq/be-secure-openssl.c | 49 +++++++++++++++++++----------------
1 file changed, 27 insertions(+), 22 deletions(-)



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* pgsql: Avoid corner-case memory leak in SSL parameter processing.
@ 2021-03-16 20:03 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2021-03-16 20:03 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Avoid corner-case memory leak in SSL parameter processing.

After reading the root cert list from the ssl_ca_file, immediately
install it as client CA list of the new SSL context.  That gives the
SSL context ownership of the list, so that SSL_CTX_free will free it.
This avoids a permanent memory leak if we fail further down in
be_tls_init(), which could happen if bogus CRL data is offered.

The leak could only amount to something if the CRL parameters get
broken after server start (else we'd just quit) and then the server
is SIGHUP'd many times without fixing the CRL data.  That's rather
unlikely perhaps, but it seems worth fixing, if only because the
code is clearer this way.

While we're here, add some comments about the memory management
aspects of this logic.

Noted by Jelte Fennema and independently by Andres Freund.
Back-patch to v10; before commit de41869b6 it doesn't matter,
since we'd not re-execute this code during SIGHUP.

Discussion: https://postgr.es/m/16160-18367e56e9a28264@postgresql.org

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/4d072bf2a031f343ef796dac6d324d9a03121183

Modified Files
--------------
src/backend/libpq/be-secure-openssl.c | 47 +++++++++++++++++++----------------
1 file changed, 26 insertions(+), 21 deletions(-)



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* pgsql: Avoid corner-case memory leak in SSL parameter processing.
@ 2021-03-16 20:03 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2021-03-16 20:03 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Avoid corner-case memory leak in SSL parameter processing.

After reading the root cert list from the ssl_ca_file, immediately
install it as client CA list of the new SSL context.  That gives the
SSL context ownership of the list, so that SSL_CTX_free will free it.
This avoids a permanent memory leak if we fail further down in
be_tls_init(), which could happen if bogus CRL data is offered.

The leak could only amount to something if the CRL parameters get
broken after server start (else we'd just quit) and then the server
is SIGHUP'd many times without fixing the CRL data.  That's rather
unlikely perhaps, but it seems worth fixing, if only because the
code is clearer this way.

While we're here, add some comments about the memory management
aspects of this logic.

Noted by Jelte Fennema and independently by Andres Freund.
Back-patch to v10; before commit de41869b6 it doesn't matter,
since we'd not re-execute this code during SIGHUP.

Discussion: https://postgr.es/m/16160-18367e56e9a28264@postgresql.org

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/6e34755560aa1bf241b498968f7ac26ea11ec15c

Modified Files
--------------
src/backend/libpq/be-secure-openssl.c | 47 +++++++++++++++++++----------------
1 file changed, 26 insertions(+), 21 deletions(-)



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* pgsql: Avoid corner-case memory leak in SSL parameter processing.
@ 2021-03-16 20:03 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2021-03-16 20:03 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Avoid corner-case memory leak in SSL parameter processing.

After reading the root cert list from the ssl_ca_file, immediately
install it as client CA list of the new SSL context.  That gives the
SSL context ownership of the list, so that SSL_CTX_free will free it.
This avoids a permanent memory leak if we fail further down in
be_tls_init(), which could happen if bogus CRL data is offered.

The leak could only amount to something if the CRL parameters get
broken after server start (else we'd just quit) and then the server
is SIGHUP'd many times without fixing the CRL data.  That's rather
unlikely perhaps, but it seems worth fixing, if only because the
code is clearer this way.

While we're here, add some comments about the memory management
aspects of this logic.

Noted by Jelte Fennema and independently by Andres Freund.
Back-patch to v10; before commit de41869b6 it doesn't matter,
since we'd not re-execute this code during SIGHUP.

Discussion: https://postgr.es/m/16160-18367e56e9a28264@postgresql.org

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/a2764d87df0475c786d021f4cd553aff2ae5f5bf

Modified Files
--------------
src/backend/libpq/be-secure-openssl.c | 47 +++++++++++++++++++----------------
1 file changed, 26 insertions(+), 21 deletions(-)



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* pgsql: Avoid corner-case memory leak in SSL parameter processing.
@ 2021-03-16 20:03 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2021-03-16 20:03 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Avoid corner-case memory leak in SSL parameter processing.

After reading the root cert list from the ssl_ca_file, immediately
install it as client CA list of the new SSL context.  That gives the
SSL context ownership of the list, so that SSL_CTX_free will free it.
This avoids a permanent memory leak if we fail further down in
be_tls_init(), which could happen if bogus CRL data is offered.

The leak could only amount to something if the CRL parameters get
broken after server start (else we'd just quit) and then the server
is SIGHUP'd many times without fixing the CRL data.  That's rather
unlikely perhaps, but it seems worth fixing, if only because the
code is clearer this way.

While we're here, add some comments about the memory management
aspects of this logic.

Noted by Jelte Fennema and independently by Andres Freund.
Back-patch to v10; before commit de41869b6 it doesn't matter,
since we'd not re-execute this code during SIGHUP.

Discussion: https://postgr.es/m/16160-18367e56e9a28264@postgresql.org

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/7ce7f2b79890ea1465c654fd0ee5271bcd01b716

Modified Files
--------------
src/backend/libpq/be-secure-openssl.c | 47 +++++++++++++++++++----------------
1 file changed, 26 insertions(+), 21 deletions(-)



^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2021-03-16 20:03 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-03-16 20:03 pgsql: Avoid corner-case memory leak in SSL parameter processing. Tom Lane <tgl@sss.pgh.pa.us>
2021-03-16 20:03 pgsql: Avoid corner-case memory leak in SSL parameter processing. Tom Lane <tgl@sss.pgh.pa.us>
2021-03-16 20:03 pgsql: Avoid corner-case memory leak in SSL parameter processing. Tom Lane <tgl@sss.pgh.pa.us>
2021-03-16 20:03 pgsql: Avoid corner-case memory leak in SSL parameter processing. Tom Lane <tgl@sss.pgh.pa.us>
2021-03-16 20:03 pgsql: Avoid corner-case memory leak in SSL parameter processing. Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox