Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751613AbdFFRsa (ORCPT ); Tue, 6 Jun 2017 13:48:30 -0400 Received: from frisell.zx2c4.com ([192.95.5.64]:38383 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751593AbdFFRs2 (ORCPT ); Tue, 6 Jun 2017 13:48:28 -0400 From: "Jason A. Donenfeld" To: "Theodore Ts'o" , Linux Crypto Mailing List , LKML , kernel-hardening@lists.openwall.com, Greg Kroah-Hartman , David Miller , Eric Biggers Cc: "Jason A. Donenfeld" , Ilya Dryomov , "Yan, Zheng" , Sage Weil Subject: [PATCH v4 07/13] ceph: ensure RNG is seeded before using Date: Tue, 6 Jun 2017 19:47:58 +0200 Message-Id: <20170606174804.31124-8-Jason@zx2c4.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170606174804.31124-1-Jason@zx2c4.com> References: <20170606174804.31124-1-Jason@zx2c4.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1105 Lines: 33 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 Cc: Ilya Dryomov Cc: "Yan, Zheng" Cc: Sage Weil --- net/ceph/ceph_common.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/net/ceph/ceph_common.c b/net/ceph/ceph_common.c index 4fd02831beed..26ab58665f77 100644 --- a/net/ceph/ceph_common.c +++ b/net/ceph/ceph_common.c @@ -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) -- 2.13.0