From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753294AbbEADNu (ORCPT ); Thu, 30 Apr 2015 23:13:50 -0400 Received: from helcar.hengli.com.au ([209.40.204.226]:44976 "EHLO helcar.hengli.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753134AbbEADNs (ORCPT ); Thu, 30 Apr 2015 23:13:48 -0400 Date: Fri, 1 May 2015 11:13:31 +0800 From: Herbert Xu To: Stephan Mueller Cc: pebolle@tiscali.nl, andreas.steffen@strongswan.org, tytso@mit.edu, sandyinchina@gmail.com, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org Subject: Re: [PATCH v3 4/6] crypto: drbg - add async seeding operation Message-ID: <20150501031331.GA32741@gondor.apana.org.au> References: <11175802.HG0pHJfshY@myon.chronox.de> <26987163.Lvcqt6Smju@myon.chronox.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <26987163.Lvcqt6Smju@myon.chronox.de> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 28, 2015 at 05:00:03AM +0200, Stephan Mueller wrote: > > @@ -1081,6 +1115,11 @@ static int drbg_seed(struct drbg_state *drbg, struct drbg_string *pers, > return -EINVAL; > } > > + /* cancel any previously invoked seeding */ > + mutex_unlock(&drbg->drbg_mutex); > + drbg_async_work_cancel(&drbg->seed_work); > + mutex_lock(&drbg->drbg_mutex); This seems dangerous and unnecessary. Releasing and reacquiring the locks may invalidate previous checks. Even if it doesn't matter today if somebody modifies the callers later on this could explode. You can easily remove this by making get_blocking_random_bytes_cb idempotent, i.e., do nothing if the work is already queued, which is what it would do anyway if you simply move the INIT_WORK out of it. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt