forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit273dcd1
committed
Ensure 64bit arithmetic when calculating tapeSpace
In tuplesort.c:inittapes(), we calculate tapeSpace by first figuringout how many 'tapes' we can use (maxTapes) and then multiplying theresult by the tape buffer overhead for each. Unfortunately, whenwe are on a system with an 8-byte long, we allow work_mem to belarger than 2GB and that allows maxTapes to be large enough that the32bit arithmetic can overflow when multiplied against the bufferoverhead.When this overflow happens, we end up adding the overflow to theamount of space available, causing the amount of memory allocated tobe larger than work_mem.Note that to reach this point, you have to set work mem to at least24GB and be sorting a set which is at least that size. Given that auser who can set work_mem to 24GB could also set it even higher, ifthey were looking to run the system out of memory, this isn'tconsidered a security issue.This overflow risk was found by the Coverity scanner.Back-patch to all supported branches, as this issue has existedsince before 8.4.1 parent1f75a5f commit273dcd1
1 file changed
+1
-1
lines changedLines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1788 | 1788 |
| |
1789 | 1789 |
| |
1790 | 1790 |
| |
1791 |
| - | |
| 1791 | + | |
1792 | 1792 |
| |
1793 | 1793 |
| |
1794 | 1794 |
| |
|
0 commit comments
Comments
(0)