Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions compiler-rt/lib/scudo/standalone/linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ bool getRandom(void *Buffer, uptr Length, UNUSED bool Blocking) {
syscall(SYS_getrandom, Buffer, Length, Blocking ? 0 : GRND_NONBLOCK);
if (ReadBytes == static_cast<ssize_t>(Length))
return true;
// If this system call is not implemented in the kernel, then we will try
// and use /dev/urandom. Otherwise, if the syscall fails, return false
// assuming that trying to read /dev/urandom will cause a delay waiting for
// the random data to be usable.
if (errno != ENOSYS)
return false;
#endif // defined(SYS_getrandom)
// Up to 256 bytes, a read off /dev/urandom will not be interrupted.
// Blocking is moot here, O_NONBLOCK has no effect when opening /dev/urandom.
Expand Down