postgresql/src/backend
Stephen Frost 273dcd1628 Ensure 64bit arithmetic when calculating tapeSpace
In tuplesort.c:inittapes(), we calculate tapeSpace by first figuring
out how many 'tapes' we can use (maxTapes) and then multiplying the
result by the tape buffer overhead for each.  Unfortunately, when
we are on a system with an 8-byte long, we allow work_mem to be
larger than 2GB and that allows maxTapes to be large enough that the
32bit arithmetic can overflow when multiplied against the buffer
overhead.

When this overflow happens, we end up adding the overflow to the
amount of space available, causing the amount of memory allocated to
be larger than work_mem.

Note that to reach this point, you have to set work mem to at least
24GB and be sorting a set which is at least that size.  Given that a
user who can set work_mem to 24GB could also set it even higher, if
they were looking to run the system out of memory, this isn't
considered a security issue.

This overflow risk was found by the Coverity scanner.

Back-patch to all supported branches, as this issue has existed
since before 8.4.
2013-07-14 16:26:16 -04:00
..
access Fix Windows build. 2013-07-08 17:28:48 +03:00
bootstrap Use an MVCC snapshot, rather than SnapshotNow, for catalog scans. 2013-07-02 09:47:01 -04:00
catalog Update messages, comments and documentation for materialized views. 2013-07-05 15:37:51 -04:00
commands Switch user ID to the object owner when populating a materialized view. 2013-07-12 18:21:22 -04:00
executor Make comments reflect that omission of SPI_gettypmod() is intentional. 2013-07-12 18:07:46 -04:00
foreign
lib pgindent run for release 9.3 2013-05-29 16:58:43 -04:00
libpq Avoid reading below the start of a stack variable in tokenize_file(). 2013-06-12 19:50:52 -04:00
main Renovate display of non-ASCII messages on Windows. 2013-06-26 11:17:33 -04:00
nodes Add a convenience routine makeFuncCall to reduce duplication. 2013-07-01 14:46:54 -04:00
optimizer Fix planning of parameterized appendrel paths with expensive join quals. 2013-07-07 22:37:24 -04:00
parser Update messages, comments and documentation for materialized views. 2013-07-05 15:37:51 -04:00
po Translation updates 2013-06-24 14:16:44 -04:00
port Use SA_RESTART for all signals, including SIGALRM. 2013-06-15 15:39:51 -04:00
postmaster Fix lack of message pluralization 2013-07-09 20:49:44 -04:00
regex pgindent run for release 9.3 2013-05-29 16:58:43 -04:00
replication Support clean switchover. 2013-06-26 02:14:37 +09:00
rewrite Update messages, comments and documentation for materialized views. 2013-07-05 15:37:51 -04:00
snowball
storage Improve scalability of WAL insertions. 2013-07-08 11:23:56 +03:00
tcop Add session_preload_libraries configuration parameter 2013-07-12 21:23:50 -04:00
tsearch pgindent run for release 9.3 2013-05-29 16:58:43 -04:00
utils Ensure 64bit arithmetic when calculating tapeSpace 2013-07-14 16:26:16 -04:00
.gitignore
common.mk
Makefile
nls.mk