forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitfd49e8f
committed
Prevent access of uninitialized memory in radix tree nodes
RT_NODE_16_SEARCH_EQ() performs comparisions using vector registerson x64-64 and aarch64. We apply a mask to the resulting bitfieldto eliminate irrelevant bits that may be set. This ensures correctbehavior, but Valgrind complains of the partially-uninitialisedvalues. So far the warnings have only occurred on aarch64, whichexplains why this hasn't been seen earlier.To fix this warning, initialize the whole fixed-sized part of the nodesupon allocation, rather than just do the minimum initialization tofunction correctly. The initialization for node48 is a bit differentin that the 256-byte slot index array must be populated with "invalidindex" rather than zero. Experimentation has shown that compilerstend to emit code that uselessly memsets that array twice. To avoidpessimizing this path, swap the order of the slot_idxs[] and isset[]arrays so we can initialize with two non-overlapping memset calls.Reported by Tomas VondraAnalysis and patch by Tom Lane, reviewed by Masahiko Sawada. Iinvestigated the behavior of memset calls to overlapping regions,leading to the above tweaks to node48 as discussed in the thread.Discussion:https://postgr.es/m/120c63ad-3d12-415f-a7bf-3da451c31bf6%40enterprisedb.com1 parentc5c8212 commitfd49e8f
1 file changed
+14
-12
lines changedLines changed: 14 additions & 12 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
541 | 541 |
| |
542 | 542 |
| |
543 | 543 |
| |
544 |
| - | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
545 | 552 |
| |
546 | 553 |
| |
547 | 554 |
| |
548 | 555 |
| |
549 | 556 |
| |
550 |
| - | |
551 |
| - | |
552 |
| - | |
553 | 557 |
| |
554 | 558 |
| |
555 | 559 |
| |
| |||
845 | 849 |
| |
846 | 850 |
| |
847 | 851 |
| |
848 |
| - | |
849 | 852 |
| |
850 | 853 |
| |
851 | 854 |
| |
| 855 | + | |
| 856 | + | |
852 | 857 |
| |
| 858 | + | |
853 | 859 |
| |
854 | 860 |
| |
855 | 861 |
| |
856 | 862 |
| |
857 | 863 |
| |
858 |
| - | |
| 864 | + | |
859 | 865 |
| |
860 | 866 |
| |
861 | 867 |
| |
862 | 868 |
| |
863 |
| - | |
864 |
| - | |
865 |
| - | |
866 |
| - | |
867 |
| - | |
868 |
| - | |
| 869 | + | |
| 870 | + | |
869 | 871 |
| |
870 | 872 |
| |
871 | 873 |
| |
|
0 commit comments
Comments
(0)