pgsql: Add overflow protection for block-related data in WAL records

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема pgsql: Add overflow protection for block-related data in WAL records
Дата
Msg-id E1oGYn5-001R0k-1u@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Add overflow protection for block-related data in WAL records

XLogRecordBlockHeader, the header holding the information for the data
related to a block, tracks the length of the data appended to the WAL
record with data_length (uint16).  This limitation in size was not
enforced by the public routine in charge of registering the data
assembled later to form the WAL record inserted, XLogRegisterBufData().
Incorrectly used, it could lead to the generation of records with some
of its data overflowed.  This commit adds some safeguards to prevent
that for the block data, complaining immediately if attempting to add to
a record block information with a size larger than UINT16_MAX, which is
the limit implied by the internal logic.

Note that this also adjusts XLogRegisterData() and XLogRegisterBufData()
so as the length of the WAL record data given by the caller is unsigned,
matching with what gets stored in XLogRecData->len.

Extracted from a larger patch by the same author.  The original patch
includes more protections when assembling a record in full that will be
looked at separately later.

Author: Matthias van de Meent
Reviewed-by: Andres Freund, Heikki Linnakangas, Michael Paquier, David
Zhang
Discussion: https://postgr.es/m/CAEze2WgGiw+LZt+vHf8tWqB_6VxeLsMeoAuod0N=ij1q17n5pw@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/ffd1b6bb6f8a2ffc929699772610c6925364dbb3

Modified Files
--------------
src/backend/access/transam/xloginsert.c | 22 ++++++++++++++++++----
src/include/access/xloginsert.h         |  4 ++--
2 files changed, 20 insertions(+), 6 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Michael Paquier
Дата:
Сообщение: Re: pgsql: Remove the restriction that the relmap must be 512 bytes.
Следующее
От: Thomas Munro
Дата:
Сообщение: Re: pgsql: Remove the restriction that the relmap must be 512 bytes.