pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Avoid out-of-bounds accesses in FDW batch inserts. 3+ messages / 1 participants [nested] [flat]
* pgsql: Avoid out-of-bounds accesses in FDW batch inserts. @ 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 Avoid out-of-bounds accesses in FDW batch inserts. Foreign data wrappers are expected to return the number of successfully inserted tuples via ExecForeignBatchInsert's numSlots parameter. Both the executor and COPY FROM use that number as the length of the slot array. If the FDW reports more rows than we sent, the backend proceeds to read past the end of the array. (postgres_fdw is acutely affected: if the remote table has an INSERT rule, the reported count may be higher.) To fix, clamp the reported count to the number of rows that were sent. This is a stopgap. Clamping keeps statements that happen to succeed today succeeding, at the cost of misreporting the number of rows. A better solution will likely involve reworking the API, but that is left as a future exercise. Reported-by: Sumedh Pathak <sumedhpathak@microsoft.com> Reported-by: Sven Klemm <sven@tigerdata.com> Author: Nathan Bossart <nathandbossart@gmail.com> Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com> Reviewed-by: Jacob Champion <champion.p@gmail.com> Reviewed-by: Tomas Vondra <tomas@vondra.me> Reviewed-by: Etsuro Fujita <etsuro.fujita@gmail.com> Security: CVE-2026-120149 Backpatch-through: 14 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/60d3e3f1fea04c5628d9290d4685f9467e08bee9 Author: Nathan Bossart <nathan@postgresql.org> Modified Files -------------- contrib/postgres_fdw/expected/postgres_fdw.out | 18 ++++++++++++++++++ contrib/postgres_fdw/sql/postgres_fdw.sql | 15 +++++++++++++++ src/backend/commands/copyfrom.c | 3 +++ src/backend/executor/nodeModifyTable.c | 9 +++++++++ 4 files changed, 45 insertions(+) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Avoid out-of-bounds accesses in FDW batch inserts. @ 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 Avoid out-of-bounds accesses in FDW batch inserts. Foreign data wrappers are expected to return the number of successfully inserted tuples via ExecForeignBatchInsert's numSlots parameter. Both the executor and COPY FROM use that number as the length of the slot array. If the FDW reports more rows than we sent, the backend proceeds to read past the end of the array. (postgres_fdw is acutely affected: if the remote table has an INSERT rule, the reported count may be higher.) To fix, clamp the reported count to the number of rows that were sent. This is a stopgap. Clamping keeps statements that happen to succeed today succeeding, at the cost of misreporting the number of rows. A better solution will likely involve reworking the API, but that is left as a future exercise. Reported-by: Sumedh Pathak <sumedhpathak@microsoft.com> Reported-by: Sven Klemm <sven@tigerdata.com> Author: Nathan Bossart <nathandbossart@gmail.com> Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com> Reviewed-by: Jacob Champion <champion.p@gmail.com> Reviewed-by: Tomas Vondra <tomas@vondra.me> Reviewed-by: Etsuro Fujita <etsuro.fujita@gmail.com> Security: CVE-2026-120149 Backpatch-through: 14 Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/ecb163f6922359890644b6adfc0b52f26ae84771 Author: Nathan Bossart <nathan@postgresql.org> Modified Files -------------- contrib/postgres_fdw/expected/postgres_fdw.out | 18 ++++++++++++++++++ contrib/postgres_fdw/sql/postgres_fdw.sql | 15 +++++++++++++++ src/backend/commands/copyfrom.c | 3 +++ src/backend/executor/nodeModifyTable.c | 9 +++++++++ 4 files changed, 45 insertions(+) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Avoid out-of-bounds accesses in FDW batch inserts. @ 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 Avoid out-of-bounds accesses in FDW batch inserts. Foreign data wrappers are expected to return the number of successfully inserted tuples via ExecForeignBatchInsert's numSlots parameter. Both the executor and COPY FROM use that number as the length of the slot array. If the FDW reports more rows than we sent, the backend proceeds to read past the end of the array. (postgres_fdw is acutely affected: if the remote table has an INSERT rule, the reported count may be higher.) To fix, clamp the reported count to the number of rows that were sent. This is a stopgap. Clamping keeps statements that happen to succeed today succeeding, at the cost of misreporting the number of rows. A better solution will likely involve reworking the API, but that is left as a future exercise. Reported-by: Sumedh Pathak <sumedhpathak@microsoft.com> Reported-by: Sven Klemm <sven@tigerdata.com> Author: Nathan Bossart <nathandbossart@gmail.com> Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com> Reviewed-by: Jacob Champion <champion.p@gmail.com> Reviewed-by: Tomas Vondra <tomas@vondra.me> Reviewed-by: Etsuro Fujita <etsuro.fujita@gmail.com> Security: CVE-2026-120149 Backpatch-through: 14 Branch ------ REL_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/1e0a55a0fb26e13a6f0b1da87dea06957780b9e4 Author: Nathan Bossart <nathan@postgresql.org> Modified Files -------------- contrib/postgres_fdw/expected/postgres_fdw.out | 18 ++++++++++++++++++ contrib/postgres_fdw/sql/postgres_fdw.sql | 15 +++++++++++++++ src/backend/commands/copyfrom.c | 3 +++ src/backend/executor/nodeModifyTable.c | 9 +++++++++ 4 files changed, 45 insertions(+) ^ 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: Avoid out-of-bounds accesses in FDW batch inserts. Noah Misch <noah@leadboat.com> 2026-11-09 14:21 pgsql: Avoid out-of-bounds accesses in FDW batch inserts. Noah Misch <noah@leadboat.com> 2026-11-09 14:21 pgsql: Avoid out-of-bounds accesses in FDW batch inserts. 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