[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 04/14] crypto: Use O_CLOEXEC in qcrypto_random_in
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PATCH v2 04/14] crypto: Use O_CLOEXEC in qcrypto_random_init |
Date: |
Wed, 13 Mar 2019 21:55:16 -0700 |
Avoids leaking the /dev/urandom fd into any child processes.
Cc: Daniel P. Berrangé <address@hidden>
Signed-off-by: Richard Henderson <address@hidden>
---
crypto/random-platform.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/crypto/random-platform.c b/crypto/random-platform.c
index 0866f216dc..8bfce99a65 100644
--- a/crypto/random-platform.c
+++ b/crypto/random-platform.c
@@ -42,9 +42,9 @@ int qcrypto_random_init(Error **errp)
#else
/* TBD perhaps also add support for BSD getentropy / Linux
* getrandom syscalls directly */
- fd = open("/dev/urandom", O_RDONLY);
+ fd = open("/dev/urandom", O_RDONLY | O_CLOEXEC);
if (fd == -1 && errno == ENOENT) {
- fd = open("/dev/random", O_RDONLY);
+ fd = open("/dev/random", O_RDONLY | O_CLOEXEC);
}
if (fd < 0) {
--
2.17.1
- [Qemu-devel] [PATCH v2 00/14] Add qemu_getrandom and ARMv8.5-RNG, Richard Henderson, 2019/03/14
- [Qemu-devel] [PATCH v2 05/14] crypto: Use getrandom for qcrypto_random_bytes, Richard Henderson, 2019/03/14
- [Qemu-devel] [PATCH v2 10/14] linux-user: Call qcrypto_init if not using -seed, Richard Henderson, 2019/03/14
- [Qemu-devel] [PATCH v2 09/14] util: Use qcrypto_random_bytes for qemu_getrandom, Richard Henderson, 2019/03/14
- [Qemu-devel] [PATCH v2 07/14] ui/vnc: Use qcrypto_random_bytes for make_challenge, Richard Henderson, 2019/03/14