| 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:21:49 |
| Message-ID: | E1xQQFp-000000003IS-1WGJ@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
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/60d3e3f1fea04c5628d9290d4685f9467e08bee9
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/commands/copyfrom.c | 3 +++
src/backend/executor/nodeModifyTable.c | 9 +++++++++
4 files changed, 45 insertions(+)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Noah Misch | 2026-11-09 14:21:50 | pgsql: Teach equalRowTypes() to safely handle dropped columns. |
| Previous Message | Noah Misch | 2026-11-09 14:21:48 | pgsql: Fix potential buffer overrun in ts_rank_cd(). |