| From: | Noah Misch <noah(at)leadboat(dot)com> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Avoid out-of-bounds accesses in FDW batch inserts. |
| Date: | 2026-11-09 14:22:14 |
| Message-ID: | E1xQQGE-000000004CZ-2luW@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
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(at)microsoft(dot)com>
Reported-by: Sven Klemm <sven(at)tigerdata(dot)com>
Author: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Reviewed-by: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Reviewed-by: Jacob Champion <champion(dot)p(at)gmail(dot)com>
Reviewed-by: Tomas Vondra <tomas(at)vondra(dot)me>
Reviewed-by: Etsuro Fujita <etsuro(dot)fujita(at)gmail(dot)com>
Security: CVE-2026-120149
Backpatch-through: 14
Branch
------
REL_14_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/56c7f155fa531846a024e11ccb0d9c83fb985fe9
Author: Nathan Bossart <nathan(at)postgresql(dot)org>
Modified Files
--------------
contrib/postgres_fdw/expected/postgres_fdw.out | 18 ++++++++++++++++++
contrib/postgres_fdw/sql/postgres_fdw.sql | 15 +++++++++++++++
src/backend/executor/nodeModifyTable.c | 9 +++++++++
3 files changed, 42 insertions(+)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Noah Misch | 2026-11-09 14:22:15 | pgsql: Forbid changing type if the rowtype is used in a foreign table |
| Previous Message | Noah Misch | 2026-11-09 14:22:13 | pgsql: Avoid use-after-free hazards in re-entrant use of pltcl. |