pgsql: Add defenses against integer overflow in dynahash numbuckets cal

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Add defenses against integer overflow in dynahash numbuckets cal
Дата
Msg-id E1Tici9-0008LQ-KZ@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Add defenses against integer overflow in dynahash numbuckets calculations.

The dynahash code requires the number of buckets in a hash table to fit
in an int; but since we calculate the desired hash table size dynamically,
there are various scenarios where we might calculate too large a value.
The resulting overflow can lead to infinite loops, division-by-zero
crashes, etc.  I (tgl) had previously installed some defenses against that
in commit 299d1716525c659f0e02840e31fbe4dea3, but that covered only one
call path.  Moreover it worked by limiting the request size to work_mem,
but in a 64-bit machine it's possible to set work_mem high enough that the
problem appears anyway.  So let's fix the problem at the root by installing
limits in the dynahash.c functions themselves.

Trouble report and patch by Jeff Davis.

Branch
------
REL9_0_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/d8caaacc9fad0395d9360481549d9a2c6ffeb1ad

Modified Files
--------------
src/backend/executor/nodeHash.c   |    4 ++-
src/backend/utils/hash/dynahash.c |   49 ++++++++++++++++++++++++++++--------
2 files changed, 41 insertions(+), 12 deletions(-)


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Add defenses against integer overflow in dynahash numbuckets cal
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Add defenses against integer overflow in dynahash numbuckets cal