Skip to content

Commit 6cef89c

Browse files
committed
fix big zone canaries from leaking the secret. Reported by Silvio Cesare
1 parent bdbecf1 commit 6cef89c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/iso_alloc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -723,8 +723,8 @@ INTERNAL_HIDDEN void *_iso_big_alloc(size_t size) {
723723

724724
/* The canaries prevents a linear overwrite of the big
725725
* zone meta data structure from either direction */
726-
big->canary_a = ((uint64_t) big ^ (uint64_t) big->user_pages_start ^ _root->big_zone_canary_secret);
727-
big->canary_b = ((uint64_t) big ^ (uint64_t) big->user_pages_start ^ _root->big_zone_canary_secret);
726+
big->canary_a = ((uint64_t) big ^ bswap_64((uint64_t) big->user_pages_start) ^ _root->big_zone_canary_secret);
727+
big->canary_b = big->canary_a;
728728

729729
return big->user_pages_start;
730730
} else {
@@ -919,7 +919,7 @@ INTERNAL_HIDDEN iso_alloc_zone *iso_find_zone_range(void *p) {
919919
* is a fast operation so we call it anytime we iterate
920920
* through the linked list of big zones */
921921
INTERNAL_HIDDEN INLINE void check_big_canary(iso_alloc_big_zone *big) {
922-
uint64_t canary = ((uint64_t) big ^ (uint64_t) big->user_pages_start ^ _root->big_zone_canary_secret);
922+
uint64_t canary = ((uint64_t) big ^ bswap_64((uint64_t) big->user_pages_start) ^ _root->big_zone_canary_secret);
923923

924924
if(UNLIKELY(big->canary_a != canary)) {
925925
LOG_AND_ABORT("Big zone %p bottom canary has been corrupted! Value: 0x%" PRIx64 " Expected: 0x%" PRIx64, big, big->canary_a, canary);

0 commit comments

Comments
 (0)