Skip to content

Commit 7e6db70

Browse files
committed
Msan: Unpoison getrandom() syscall result
1 parent 5c0a9a4 commit 7e6db70

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

ext/standard/random.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
# endif
3939
#endif
4040

41+
#if __has_feature(memory_sanitizer)
42+
# include <sanitizer/msan_interface.h>
43+
#endif
44+
4145
#ifdef ZTS
4246
int random_globals_id;
4347
#else
@@ -133,6 +137,10 @@ PHPAPI int php_random_bytes(void *bytes, size_t size, zend_bool should_throw)
133137
}
134138
}
135139

140+
#if __has_feature(memory_sanitizer)
141+
/* MSan does not instrument manual syscall invocations. */
142+
__msan_unpoison(bytes + read_bytes, n);
143+
#endif
136144
read_bytes += (size_t) n;
137145
}
138146
#endif

0 commit comments

Comments
 (0)