]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
ceph: ensure RNG is seeded before using
authorJason A. Donenfeld <Jason@zx2c4.com>
Thu, 8 Jun 2017 02:44:54 +0000 (22:44 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 20 Jun 2017 02:06:28 +0000 (22:06 -0400)
Ceph uses the RNG for various nonce generations, and it shouldn't accept
using bad randomness. So, we wait for the RNG to be properly seeded. We
do this by calling wait_for_random_bytes() in a function that is
certainly called in process context, early on, so that all subsequent
calls to get_random_bytes are necessarily acceptable.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Cc: Ilya Dryomov <idryomov@gmail.com>
Cc: "Yan, Zheng" <zyan@redhat.com>
Cc: Sage Weil <sage@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
net/ceph/ceph_common.c

index 4fd02831beed20fb3d98475c7da2a0b4f2818513..26ab58665f772177c81baf24a09107de08696a1b 100644 (file)
@@ -611,7 +611,11 @@ struct ceph_client *ceph_create_client(struct ceph_options *opt, void *private)
 {
        struct ceph_client *client;
        struct ceph_entity_addr *myaddr = NULL;
-       int err = -ENOMEM;
+       int err;
+
+       err = wait_for_random_bytes();
+       if (err < 0)
+               return ERR_PTR(err);
 
        client = kzalloc(sizeof(*client), GFP_KERNEL);
        if (client == NULL)