pgsql: Avoid out-of-bounds accesses in FDW batch inserts.

Поиск
Список
Период
Сортировка
Искать

pgsql: Avoid out-of-bounds accesses in FDW batch inserts.

От:
Noah Misch <noah@leadboat.com>
Дата:
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 
Reported-by: Sven Klemm 
Author: Nathan Bossart 
Reviewed-by: Bertrand Drouvot 
Reviewed-by: Jacob Champion 
Reviewed-by: Tomas Vondra 
Reviewed-by: Etsuro Fujita 
Security: CVE-2026-120149
Backpatch-through: 14

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/1e0a55a0fb26e13a6f0b1da87dea06957780b9e4
Author: Nathan Bossart 

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(+)

FAQ