pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: libpq: handle GSS credentials more sanely. 5+ messages / 1 participants [nested] [flat]
* pgsql: libpq: handle GSS credentials more sanely. @ 2026-10-30 17:56 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 5+ messages in thread From: Tom Lane @ 2026-10-30 17:56 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org libpq: handle GSS credentials more sanely. pg_GSS_have_cred_cache() always acquires new GSS credentials. If we already had some, they were just leaked due to overwriting conn->gcred, and that's a nontrivial amount of memory (around 16K according to reporter). Unfortunately, pg_GSS_continue() did this each time through, and it is typically called more than once in a GSSAPI connection cycle. So repeated connections using GSS authentication could leak substantial amounts of memory. IMO the source of this problem is really the poorly-designed API of pg_GSS_have_cred_cache(): it's unclear that it always gets new credentials. Let's rename it and remove the unnecessary pointer parameter to make its behavior clearer. To add insult to injury, pg_GSS_continue() shouldn't even be trying to acquire credentials unless GSS delegation is enabled, which it is not by default; so the whole effort is often wasted. Problems evidently introduced by 6633cfb21, so back-patch to v16. Bug: #19411 Reported-by: Matt Carter <Matt.Carter@twosigma.com> Diagnosed-by: Matt Carter <Matt.Carter@twosigma.com> Author: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/19411-0440c8897a04b638@postgresql.org Backpatch-through: 16 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/1c9efb57ec974b9c84df041644a39d8d4cc03004 Modified Files -------------- src/interfaces/libpq/fe-auth.c | 10 ++++++---- src/interfaces/libpq/fe-connect.c | 16 +++++++++++----- src/interfaces/libpq/fe-gssapi-common.c | 15 ++++++--------- src/interfaces/libpq/fe-gssapi-common.h | 2 +- src/interfaces/libpq/fe-secure-gssapi.c | 4 ++-- 5 files changed, 26 insertions(+), 21 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: libpq: handle GSS credentials more sanely. @ 2026-10-30 17:56 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 5+ messages in thread From: Tom Lane @ 2026-10-30 17:56 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org libpq: handle GSS credentials more sanely. pg_GSS_have_cred_cache() always acquires new GSS credentials. If we already had some, they were just leaked due to overwriting conn->gcred, and that's a nontrivial amount of memory (around 16K according to reporter). Unfortunately, pg_GSS_continue() did this each time through, and it is typically called more than once in a GSSAPI connection cycle. So repeated connections using GSS authentication could leak substantial amounts of memory. IMO the source of this problem is really the poorly-designed API of pg_GSS_have_cred_cache(): it's unclear that it always gets new credentials. Let's rename it and remove the unnecessary pointer parameter to make its behavior clearer. To add insult to injury, pg_GSS_continue() shouldn't even be trying to acquire credentials unless GSS delegation is enabled, which it is not by default; so the whole effort is often wasted. Problems evidently introduced by 6633cfb21, so back-patch to v16. Bug: #19411 Reported-by: Matt Carter <Matt.Carter@twosigma.com> Diagnosed-by: Matt Carter <Matt.Carter@twosigma.com> Author: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/19411-0440c8897a04b638@postgresql.org Backpatch-through: 16 Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/5aed88ff9f36422de302c7fe406c23cd732934b9 Modified Files -------------- src/interfaces/libpq/fe-auth.c | 10 ++++++---- src/interfaces/libpq/fe-connect.c | 16 +++++++++++----- src/interfaces/libpq/fe-gssapi-common.c | 15 ++++++--------- src/interfaces/libpq/fe-gssapi-common.h | 2 +- src/interfaces/libpq/fe-secure-gssapi.c | 4 ++-- 5 files changed, 26 insertions(+), 21 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: libpq: handle GSS credentials more sanely. @ 2026-10-30 17:56 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 5+ messages in thread From: Tom Lane @ 2026-10-30 17:56 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org libpq: handle GSS credentials more sanely. pg_GSS_have_cred_cache() always acquires new GSS credentials. If we already had some, they were just leaked due to overwriting conn->gcred, and that's a nontrivial amount of memory (around 16K according to reporter). Unfortunately, pg_GSS_continue() did this each time through, and it is typically called more than once in a GSSAPI connection cycle. So repeated connections using GSS authentication could leak substantial amounts of memory. IMO the source of this problem is really the poorly-designed API of pg_GSS_have_cred_cache(): it's unclear that it always gets new credentials. Let's rename it and remove the unnecessary pointer parameter to make its behavior clearer. To add insult to injury, pg_GSS_continue() shouldn't even be trying to acquire credentials unless GSS delegation is enabled, which it is not by default; so the whole effort is often wasted. Problems evidently introduced by 6633cfb21, so back-patch to v16. Bug: #19411 Reported-by: Matt Carter <Matt.Carter@twosigma.com> Diagnosed-by: Matt Carter <Matt.Carter@twosigma.com> Author: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/19411-0440c8897a04b638@postgresql.org Backpatch-through: 16 Branch ------ REL_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/94d625f5d938e0a01cb80d85cc242ff8a64b3f54 Modified Files -------------- src/interfaces/libpq/fe-auth.c | 10 ++++++---- src/interfaces/libpq/fe-connect.c | 16 +++++++++++----- src/interfaces/libpq/fe-gssapi-common.c | 15 ++++++--------- src/interfaces/libpq/fe-gssapi-common.h | 2 +- src/interfaces/libpq/fe-secure-gssapi.c | 4 ++-- 5 files changed, 26 insertions(+), 21 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: libpq: handle GSS credentials more sanely. @ 2026-10-30 17:56 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 5+ messages in thread From: Tom Lane @ 2026-10-30 17:56 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org libpq: handle GSS credentials more sanely. pg_GSS_have_cred_cache() always acquires new GSS credentials. If we already had some, they were just leaked due to overwriting conn->gcred, and that's a nontrivial amount of memory (around 16K according to reporter). Unfortunately, pg_GSS_continue() did this each time through, and it is typically called more than once in a GSSAPI connection cycle. So repeated connections using GSS authentication could leak substantial amounts of memory. IMO the source of this problem is really the poorly-designed API of pg_GSS_have_cred_cache(): it's unclear that it always gets new credentials. Let's rename it and remove the unnecessary pointer parameter to make its behavior clearer. To add insult to injury, pg_GSS_continue() shouldn't even be trying to acquire credentials unless GSS delegation is enabled, which it is not by default; so the whole effort is often wasted. Problems evidently introduced by 6633cfb21, so back-patch to v16. Bug: #19411 Reported-by: Matt Carter <Matt.Carter@twosigma.com> Diagnosed-by: Matt Carter <Matt.Carter@twosigma.com> Author: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/19411-0440c8897a04b638@postgresql.org Backpatch-through: 16 Branch ------ REL_17_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/df9e6d7c7be5b178bf2c04f74d2f5dd1f7ec77d0 Modified Files -------------- src/interfaces/libpq/fe-auth.c | 10 ++++++---- src/interfaces/libpq/fe-connect.c | 16 +++++++++++----- src/interfaces/libpq/fe-gssapi-common.c | 15 ++++++--------- src/interfaces/libpq/fe-gssapi-common.h | 2 +- src/interfaces/libpq/fe-secure-gssapi.c | 4 ++-- 5 files changed, 26 insertions(+), 21 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: libpq: handle GSS credentials more sanely. @ 2026-10-30 17:56 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 5+ messages in thread From: Tom Lane @ 2026-10-30 17:56 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org libpq: handle GSS credentials more sanely. pg_GSS_have_cred_cache() always acquires new GSS credentials. If we already had some, they were just leaked due to overwriting conn->gcred, and that's a nontrivial amount of memory (around 16K according to reporter). Unfortunately, pg_GSS_continue() did this each time through, and it is typically called more than once in a GSSAPI connection cycle. So repeated connections using GSS authentication could leak substantial amounts of memory. IMO the source of this problem is really the poorly-designed API of pg_GSS_have_cred_cache(): it's unclear that it always gets new credentials. Let's rename it and remove the unnecessary pointer parameter to make its behavior clearer. To add insult to injury, pg_GSS_continue() shouldn't even be trying to acquire credentials unless GSS delegation is enabled, which it is not by default; so the whole effort is often wasted. Problems evidently introduced by 6633cfb21, so back-patch to v16. Bug: #19411 Reported-by: Matt Carter <Matt.Carter@twosigma.com> Diagnosed-by: Matt Carter <Matt.Carter@twosigma.com> Author: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/19411-0440c8897a04b638@postgresql.org Backpatch-through: 16 Branch ------ REL_16_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/72216a24544b893dc105e811f0ec27b3c036575b Modified Files -------------- src/interfaces/libpq/fe-auth.c | 10 ++++++---- src/interfaces/libpq/fe-connect.c | 23 +++++++++++++++++------ src/interfaces/libpq/fe-gssapi-common.c | 15 ++++++--------- src/interfaces/libpq/fe-gssapi-common.h | 2 +- src/interfaces/libpq/fe-secure-gssapi.c | 4 ++-- 5 files changed, 32 insertions(+), 22 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2026-10-30 17:56 UTC | newest] Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-10-30 17:56 pgsql: libpq: handle GSS credentials more sanely. Tom Lane <tgl@sss.pgh.pa.us> 2026-10-30 17:56 pgsql: libpq: handle GSS credentials more sanely. Tom Lane <tgl@sss.pgh.pa.us> 2026-10-30 17:56 pgsql: libpq: handle GSS credentials more sanely. Tom Lane <tgl@sss.pgh.pa.us> 2026-10-30 17:56 pgsql: libpq: handle GSS credentials more sanely. Tom Lane <tgl@sss.pgh.pa.us> 2026-10-30 17:56 pgsql: libpq: handle GSS credentials more sanely. 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