pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Hold a reference on a Perl array or hash while scanning it. 3+ messages / 1 participants [nested] [flat]
* pgsql: Hold a reference on a Perl array or hash while scanning it. @ 2026-11-09 14:21 Noah Misch <noah@leadboat.com> 0 siblings, 0 replies; 3+ messages in thread From: Noah Misch @ 2026-11-09 14:21 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Hold a reference on a Perl array or hash while scanning it. Previously we assumed that the object would stick around while we examined it, but there are a few ways that the last refcount could get dropped meanwhile, allowing the object to be recycled and creating a use-after-free hazard. To prevent that, we must acquire our own refcount and release it when we're done. The tricky part is to ensure that the refcount gets released if an error is thrown partway through. A TRY/FINALLY block would work, but that answer would be expensive and notationally invasive. The method used here is to push a refcount-carrying RV onto Perl's temporaries stack so that temporaries cleanup will release the reference. A simple benchmark suggests that that adds just a couple percent of overhead, which seems acceptable. The first draft of this patch was created by Anthropic's OSS program. Reported-by: Anthropic OSS program Author: Tom Lane <tgl@sss.pgh.pa.us> Co-authored-by: Anthropic OSS program Backpatch-through: 14 Security: CVE-2026-116320 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/bcb007a721371dfebaa20b5250784b896a33304f Author: Tom Lane <tgl@sss.pgh.pa.us> Modified Files -------------- contrib/hstore_plperl/hstore_plperl.c | 9 ++++ contrib/jsonb_plperl/jsonb_plperl.c | 22 +++++++++- src/pl/plperl/plperl.c | 83 ++++++++++++++++++++++++++++++++--- 3 files changed, 106 insertions(+), 8 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Hold a reference on a Perl array or hash while scanning it. @ 2026-11-09 14:21 Noah Misch <noah@leadboat.com> 0 siblings, 0 replies; 3+ messages in thread From: Noah Misch @ 2026-11-09 14:21 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Hold a reference on a Perl array or hash while scanning it. Previously we assumed that the object would stick around while we examined it, but there are a few ways that the last refcount could get dropped meanwhile, allowing the object to be recycled and creating a use-after-free hazard. To prevent that, we must acquire our own refcount and release it when we're done. The tricky part is to ensure that the refcount gets released if an error is thrown partway through. A TRY/FINALLY block would work, but that answer would be expensive and notationally invasive. The method used here is to push a refcount-carrying RV onto Perl's temporaries stack so that temporaries cleanup will release the reference. A simple benchmark suggests that that adds just a couple percent of overhead, which seems acceptable. The first draft of this patch was created by Anthropic's OSS program. Reported-by: Anthropic OSS program Author: Tom Lane <tgl@sss.pgh.pa.us> Co-authored-by: Anthropic OSS program Backpatch-through: 14 Security: CVE-2026-116320 Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/f3e7fe9c6582e3c5abd2a1e383b2d721bc911b75 Author: Tom Lane <tgl@sss.pgh.pa.us> Modified Files -------------- contrib/hstore_plperl/hstore_plperl.c | 9 ++++ contrib/jsonb_plperl/jsonb_plperl.c | 22 ++++++++- src/pl/plperl/plperl.c | 84 +++++++++++++++++++++++++++++++---- 3 files changed, 106 insertions(+), 9 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Hold a reference on a Perl array or hash while scanning it. @ 2026-11-09 14:21 Noah Misch <noah@leadboat.com> 0 siblings, 0 replies; 3+ messages in thread From: Noah Misch @ 2026-11-09 14:21 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Hold a reference on a Perl array or hash while scanning it. Previously we assumed that the object would stick around while we examined it, but there are a few ways that the last refcount could get dropped meanwhile, allowing the object to be recycled and creating a use-after-free hazard. To prevent that, we must acquire our own refcount and release it when we're done. The tricky part is to ensure that the refcount gets released if an error is thrown partway through. A TRY/FINALLY block would work, but that answer would be expensive and notationally invasive. The method used here is to push a refcount-carrying RV onto Perl's temporaries stack so that temporaries cleanup will release the reference. A simple benchmark suggests that that adds just a couple percent of overhead, which seems acceptable. The first draft of this patch was created by Anthropic's OSS program. Reported-by: Anthropic OSS program Author: Tom Lane <tgl@sss.pgh.pa.us> Co-authored-by: Anthropic OSS program Backpatch-through: 14 Security: CVE-2026-116320 Branch ------ REL_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/5215e9d6a13955c949bfe07b643927b733bd0033 Author: Tom Lane <tgl@sss.pgh.pa.us> Modified Files -------------- contrib/hstore_plperl/hstore_plperl.c | 9 ++++ contrib/jsonb_plperl/jsonb_plperl.c | 22 ++++++++- src/pl/plperl/plperl.c | 84 +++++++++++++++++++++++++++++++---- 3 files changed, 106 insertions(+), 9 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2026-11-09 14:21 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-11-09 14:21 pgsql: Hold a reference on a Perl array or hash while scanning it. Noah Misch <noah@leadboat.com> 2026-11-09 14:21 pgsql: Hold a reference on a Perl array or hash while scanning it. Noah Misch <noah@leadboat.com> 2026-11-09 14:21 pgsql: Hold a reference on a Perl array or hash while scanning it. Noah Misch <noah@leadboat.com>
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