Fix MSan false-positive in zend_max_execution_timer (#15408)

Explicitly mark memory regions as unpoisoned for zend_max_execution_timer on ZTS, as MemorySanitizer in clang >= 18 causes false positives.
This commit is contained in:
Go Kudo 2024-08-17 02:54:03 +09:00 committed by GitHub
parent 8c3f5f99f3
commit ec9cdcd2bc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -24,6 +24,10 @@
#include <sys/syscall.h>
#include <sys/types.h>
#if __has_feature(memory_sanitizer)
# include <sanitizer/msan_interface.h>
#endif
#include "zend.h"
#include "zend_globals.h"
@ -47,6 +51,12 @@ ZEND_API void zend_max_execution_timer_init(void) /* {{{ */
sev.sigev_signo = SIGRTMIN;
sev.sigev_notify_thread_id = (pid_t) syscall(SYS_gettid);
#if __has_feature(memory_sanitizer)
/* MSan does not intercept timer_create() */
__msan_unpoison(&EG(max_execution_timer_timer),
sizeof(EG(max_execution_timer_timer)));
#endif
// Measure wall time instead of CPU time as originally planned now that it is possible https://github.com/php/php-src/pull/6504#issuecomment-1370303727
if (timer_create(CLOCK_BOOTTIME, &sev, &EG(max_execution_timer_timer)) != 0) {
zend_strerror_noreturn(E_ERROR, errno, "Could not create timer");