File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -171,6 +171,22 @@ static size_t _real_page_size = ZEND_MM_PAGE_SIZE;
171171#endif
172172
173173#ifdef __SANITIZE_ADDRESS__
174+
175+ /*
176+ Poisoning uses the following rules:
177+ * Always poison memory (re)allocated by private (non-ZEND_API) allocation functions before returning it
178+ * Unpoison memory (re)allocated by public (ZEND_API) allocation functions before returning within the ZEND_API function
179+ * Always poison freed memory
180+ * Always poison unused memory during reallocation (where new_size < old_size)
181+ * When accessing private heap structures and fields, always unpoison before accessing and repoison immediately after
182+ * An exception to the above (for simplicity) is the main heap datastructure,
183+ which is poisoned only when entering a ZEND_API function and repoisoned before exiting.
184+ * When working with custom handlers, remember that the tracked_malloc implementation
185+ removes the custom handlers, re-enters the current Zend allocator function,
186+ then re-sets the custom handlers, so when invoking custom handlers always
187+ remember that the heap may be poisoned after invocation.
188+ */
189+
174190# include <sanitizer/asan_interface.h>
175191
176192# if 0
You can’t perform that action at this time.
0 commit comments