From: Richard Henderson Date: Thu, 14 Mar 2019 04:05:54 +0000 (-0700) Subject: crypto: Use O_CLOEXEC in qcrypto_random_init X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=e9979ca64e5e4a150f5346de3982f02f54c41076;p=qemu.git crypto: Use O_CLOEXEC in qcrypto_random_init Avoids leaking the /dev/urandom fd into any child processes. Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Daniel P. Berrangé Signed-off-by: Richard Henderson --- diff --git a/crypto/random-platform.c b/crypto/random-platform.c index 260b64564d..6df40744c7 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) {