aboutsummaryrefslogtreecommitdiff
path: root/compiler-rt
diff options
context:
space:
mode:
authorDavid CARLIER <devnexen@gmail.com>2024-01-18 05:46:50 +0000
committerGitHub <noreply@github.com>2024-01-18 05:46:50 +0000
commitd83d1cb89cf80cda9d85e61c7b43f69446638865 (patch)
treeb69129b74d2ffd138a3c2f910c2dbe50825ac002 /compiler-rt
parentf01b6ca8bed49bdb957607456aed29ff8ee97109 (diff)
downloadllvm-d83d1cb89cf80cda9d85e61c7b43f69446638865.zip
llvm-d83d1cb89cf80cda9d85e61c7b43f69446638865.tar.gz
llvm-d83d1cb89cf80cda9d85e61c7b43f69446638865.tar.bz2
[compiler-rt] making getrandom call blocking. (#78340)
except when `GRND_NONBLOCK` is present in the flags.
Diffstat (limited to 'compiler-rt')
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc8
1 files changed, 7 insertions, 1 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
index 77fa1b4..1b56beb 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -9965,7 +9965,13 @@ INTERCEPTOR(void, sl_free, void *sl, int freeall) {
INTERCEPTOR(SSIZE_T, getrandom, void *buf, SIZE_T buflen, unsigned int flags) {
void *ctx;
COMMON_INTERCEPTOR_ENTER(ctx, getrandom, buf, buflen, flags);
- SSIZE_T n = REAL(getrandom)(buf, buflen, flags);
+ // If GRND_NONBLOCK is set in the flags, it is non blocking.
+ static const int grnd_nonblock = 1;
+ SSIZE_T n;
+ if ((flags & grnd_nonblock))
+ n = REAL(getrandom)(buf, buflen, flags);
+ else
+ n = COMMON_INTERCEPTOR_BLOCK_REAL(getrandom)(buf, buflen, flags);
if (n > 0) {
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, buf, n);
}