forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit8fcb32d
committed
Add more protections in WAL record APIs against overflows
This commit adds a limit to the size of an XLogRecord at 1020MB, basedon a suggestion by Heikki Linnakangas. This counts for the overheadneeded by the XLogReader when allocating the memory it needs to read arecord in DecodeXLogRecordRequiredSpace(), based on the record size. Anassertion based on that is added to detect that any additions in theXLogReader facilities would not cause any overflows. If that's ever thecase, the upper bound allowed would need to be adjusted.Before this, it was possible for an external module to create WALrecords large enough to be assembled but not replayable, causingfailures when replaying such WAL records on standbys. One casementioned where this is possible is the in-core functionpg_logical_emit_message() (wrapper for LogLogicalMessage), that allowsto emit WAL records with an arbitrary amount of data potentially higherthan the replay limit of approximately 1GB (limit of a palloc, minus theoverhead needed by a XLogReader).This commit is a follow-up offfd1b6b that has added similar protectionsfor the block-level data. Here, the checks are extended to the wholerecord length, mainrdata_len being extended from uint32 to uint64 withthe routines registering buffer and record data still limited to uint32to minimize the checks when assembling a record. All the error messagesrelated to overflow checks are improved to provide more context aboutthe error happening.Author: Matthias van de MeentReviewed-by: Andres Freund, Heikki Linnakangas, Michael PaquierDiscussion:https://postgr.es/m/CAEze2WgGiw+LZt+vHf8tWqB_6VxeLsMeoAuod0N=ij1q17n5pw@mail.gmail.com1 parent26158b8 commit8fcb32d
File tree
2 files changed
+65
-8
lines changed- src
- backend/access/transam
- include/access
2 files changed
+65
-8
lines changedLines changed: 54 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
98 | 98 |
| |
99 | 99 |
| |
100 | 100 |
| |
101 |
| - | |
| 101 | + | |
102 | 102 |
| |
103 | 103 |
| |
104 | 104 |
| |
| |||
355 | 355 |
| |
356 | 356 |
| |
357 | 357 |
| |
358 |
| - | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
359 | 362 |
| |
360 | 363 |
| |
361 | 364 |
| |
| |||
405 | 408 |
| |
406 | 409 |
| |
407 | 410 |
| |
408 |
| - | |
409 |
| - | |
410 |
| - | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
411 | 421 |
| |
412 | 422 |
| |
413 | 423 |
| |
| |||
527 | 537 |
| |
528 | 538 |
| |
529 | 539 |
| |
530 |
| - | |
| 540 | + | |
531 | 541 |
| |
532 | 542 |
| |
533 | 543 |
| |
| |||
841 | 851 |
| |
842 | 852 |
| |
843 | 853 |
| |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
844 | 864 |
| |
845 |
| - | |
| 865 | + | |
846 | 866 |
| |
847 | 867 |
| |
848 | 868 |
| |
| |||
872 | 892 |
| |
873 | 893 |
| |
874 | 894 |
| |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
875 | 909 |
| |
876 | 910 |
| |
877 | 911 |
| |
878 | 912 |
| |
879 | 913 |
| |
880 | 914 |
| |
881 |
| - | |
| 915 | + | |
882 | 916 |
| |
883 | 917 |
| |
884 | 918 |
| |
| |||
1297 | 1331 |
| |
1298 | 1332 |
| |
1299 | 1333 |
| |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
1300 | 1346 |
| |
1301 | 1347 |
| |
1302 | 1348 |
| |
|
Lines changed: 11 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
62 | 62 |
| |
63 | 63 |
| |
64 | 64 |
| |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
65 | 76 |
| |
66 | 77 |
| |
67 | 78 |
| |
|
0 commit comments
Comments
(0)