Skip to content

Commit 2e2efc3

Browse files
committed
More poisoning
1 parent 5bd3345 commit 2e2efc3

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

Zend/zend_alloc.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,6 +1208,7 @@ static zend_never_inline void zend_mm_free_pages(zend_mm_heap *heap, zend_mm_chu
12081208

12091209
static zend_always_inline void zend_mm_free_large(zend_mm_heap *heap, zend_mm_chunk *chunk, int page_num, int pages_count)
12101210
{
1211+
printf("Freeing large %p\n", chunk);
12111212
#if ZEND_MM_STAT
12121213
heap->size -= pages_count * ZEND_MM_PAGE_SIZE;
12131214
#endif
@@ -1729,7 +1730,7 @@ static zend_always_inline void *zend_mm_realloc_heap(zend_mm_heap *heap, void *p
17291730
} else {
17301731
ret = zend_mm_realloc_huge(heap, ptr, size, copy_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
17311732
}
1732-
printf("Reallocated %zu bytes from %p to %p\n", size, ptr, ret);
1733+
printf("Reallocated (1) %zu bytes from %p to %p\n", size, ptr, ret);
17331734
return ret;
17341735
} else {
17351736
zend_mm_chunk *chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(ptr, ZEND_MM_CHUNK_SIZE);
@@ -1768,6 +1769,7 @@ static zend_always_inline void *zend_mm_realloc_heap(zend_mm_heap *heap, void *p
17681769
zend_mm_free_small(heap, ptr, old_bin_num);
17691770
} else {
17701771
/* reallocation in-place */
1772+
ZEND_ASAN_UNPOISON_MEMORY_REGION(ret, size);
17711773
ret = ptr;
17721774
}
17731775
} else if (size <= ZEND_MM_MAX_SMALL_SIZE) {
@@ -1801,7 +1803,7 @@ static zend_always_inline void *zend_mm_realloc_heap(zend_mm_heap *heap, void *p
18011803
dbg->orig_lineno = __zend_orig_lineno;
18021804
#endif
18031805
ZEND_ASAN_POISON_CHUNK_HEADER_NOT_HEAP(chunk, heap);
1804-
printf("Reallocated %zu bytes from %p to %p\n", size, ptr, ret);
1806+
printf("Reallocated (2) %zu bytes from %p to %p\n", size, ptr, ret);
18051807
return ret;
18061808
} while (0);
18071809

@@ -1820,7 +1822,7 @@ static zend_always_inline void *zend_mm_realloc_heap(zend_mm_heap *heap, void *p
18201822
dbg->orig_lineno = __zend_orig_lineno;
18211823
#endif
18221824
ZEND_ASAN_POISON_CHUNK_HEADER_NOT_HEAP(chunk, heap);
1823-
printf("Reallocated %zu bytes from %p to %p\n", size, ptr, ptr);
1825+
printf("Reallocated (3) %zu bytes from %p to %p\n", size, ptr, ptr);
18241826
return ptr;
18251827
} else if (new_size < old_size) {
18261828
/* free tail pages */
@@ -1844,7 +1846,7 @@ static zend_always_inline void *zend_mm_realloc_heap(zend_mm_heap *heap, void *p
18441846
dbg->orig_lineno = __zend_orig_lineno;
18451847
#endif
18461848
ZEND_ASAN_POISON_CHUNK_HEADER_NOT_HEAP(chunk, heap);
1847-
printf("Reallocated %zu bytes from %p to %p\n", size, ptr, ptr);
1849+
printf("Reallocated (4) %zu bytes from %p to %p\n", size, ptr, ptr);
18481850
return ptr;
18491851
} else /* if (new_size > old_size) */ {
18501852
int new_pages_count = (int)(new_size / ZEND_MM_PAGE_SIZE);
@@ -1874,7 +1876,7 @@ static zend_always_inline void *zend_mm_realloc_heap(zend_mm_heap *heap, void *p
18741876
dbg->orig_lineno = __zend_orig_lineno;
18751877
#endif
18761878
ZEND_ASAN_POISON_CHUNK_HEADER_NOT_HEAP(chunk, heap);
1877-
printf("Reallocated %zu bytes from %p to %p\n", size, ptr, ptr);
1879+
printf("Reallocated (5) %zu bytes from %p to %p\n", size, ptr, ptr);
18781880
return ptr;
18791881
}
18801882
}
@@ -1888,7 +1890,7 @@ static zend_always_inline void *zend_mm_realloc_heap(zend_mm_heap *heap, void *p
18881890

18891891
copy_size = MIN(old_size, copy_size);
18901892
ret = zend_mm_realloc_slow(heap, ptr, size, copy_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1891-
printf("Reallocated %zu bytes from %p to %p\n", size, ptr, ret);
1893+
printf("Reallocated (6) %zu bytes from %p to %p\n", size, ptr, ret);
18921894
return ret;
18931895
}
18941896

@@ -2051,6 +2053,8 @@ static void *zend_mm_alloc_huge(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_D
20512053

20522054
static void zend_mm_free_huge(zend_mm_heap *heap, void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
20532055
{
2056+
printf("Freeing huge %p\n", ptr);
2057+
20542058
size_t size;
20552059

20562060
ZEND_MM_CHECK(ZEND_MM_ALIGNED_OFFSET(ptr, ZEND_MM_CHUNK_SIZE) == 0, "zend_mm_heap corrupted");

0 commit comments

Comments
 (0)