From patchwork Thu May 21 08:19:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herbert Xu X-Patchwork-Id: 6453091 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 249499F1CC for ; Thu, 21 May 2015 08:20:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4F0C720411 for ; Thu, 21 May 2015 08:20:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 39C4C203E5 for ; Thu, 21 May 2015 08:20:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754944AbbEUIUa (ORCPT ); Thu, 21 May 2015 04:20:30 -0400 Received: from helcar.hengli.com.au ([209.40.204.226]:45586 "EHLO helcar.hengli.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751929AbbEUIUJ (ORCPT ); Thu, 21 May 2015 04:20:09 -0400 Received: from gondolin.me.apana.org.au ([192.168.0.6]) by norbury.hengli.com.au with esmtp (Exim 4.80 #3 (Debian)) id 1YvLhv-0004BL-NQ; Thu, 21 May 2015 18:19:59 +1000 Received: from herbert by gondolin.me.apana.org.au with local (Exim 4.80) (envelope-from ) id 1YvLhq-0005pB-Qo; Thu, 21 May 2015 16:19:54 +0800 Date: Thu, 21 May 2015 16:19:54 +0800 From: Herbert Xu To: Stephan Mueller Cc: pebolle@tiscali.nl, andreas.steffen@strongswan.org, tytso@mit.edu, sandyinchina@gmail.com, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: random: Wake up all getrandom(2) callers when pool is ready Message-ID: <20150521081953.GA22301@gondor.apana.org.au> References: <3340545.QDDPvU7BuN@tachyon.chronox.de> <12904468.qCSNRrkb6t@tachyon.chronox.de> <20150520214408.GA17264@gondor.apana.org.au> <9182932.rX0DhQWPrJ@tachyon.chronox.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <9182932.rX0DhQWPrJ@tachyon.chronox.de> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, May 21, 2015 at 09:55:17AM +0200, Stephan Mueller wrote: > > So, I will create a 2nd wait queue in random.c for uninterruptible waits, > change the get_blocking_random_bytes back to void and use wait_event to wait > for the initialization. Hold your horses. You don't need a second queue, you just need to change wake_up_interruptible to wake_up. Hmm, in fact shouldn't this be wake_up_all? Otherwise what are the other getrandom(2) callers going to do? Ted? ---8<--- If more than one application invokes getrandom(2) before the pool is ready, then all bar one will be stuck forever because we use wake_up_interruptible which wakes up a single task. This patch replaces it with wake_up_all. Signed-off-by: Herbert Xu Cheers, diff --git a/drivers/char/random.c b/drivers/char/random.c index 9cd6968..8b8c46b 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -660,7 +660,7 @@ retry: r->entropy_total = 0; if (r == &nonblocking_pool) { prandom_reseed_late(); - wake_up_interruptible(&urandom_init_wait); + wake_up_all(&urandom_init_wait); pr_notice("random: %s pool is initialized\n", r->name); } }