Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761443AbXLMGo4 (ORCPT ); Thu, 13 Dec 2007 01:44:56 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1759397AbXLMGht (ORCPT ); Thu, 13 Dec 2007 01:37:49 -0500 Received: from pentafluge.infradead.org ([213.146.154.40]:56471 "EHLO pentafluge.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759371AbXLMGhr (ORCPT ); Thu, 13 Dec 2007 01:37:47 -0500 Date: Wed, 12 Dec 2007 22:34:58 -0800 From: Greg KH To: linux-kernel@vger.kernel.org, stable@kernel.org, davem@davemloft.net Cc: Justin Forbes , Zwane Mwaikambo , "Theodore Ts'o" , Randy Dunlap , Dave Jones , Chuck Wolber , Chris Wedgwood , Michael Krufky , Chuck Ebbert , Domenico Andreoli , torvalds@linux-foundation.org, akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk, Herbert Xu Subject: [patch 21/36] CRYPTO api: Fix potential race in crypto_remove_spawn Message-ID: <20071213063458.GV25301@kroah.com> References: <20071213062511.265908583@mini.kroah.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename="crypto-api-fix-potential-race-in-crypto_remove_spawn.patch" In-Reply-To: <20071213063308.GA25301@kroah.com> User-Agent: Mutt/1.5.16 (2007-06-09) X-Bad-Reply: References and In-Reply-To but no 'Re:' in Subject. Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1573 Lines: 55 2.6.22-stable review patch. If anyone has any objections, please let us know. ------------------ From: Herbert Xu [CRYPTO] api: Fix potential race in crypto_remove_spawn [ Upstream commit: 38cb2419f544ad413c7f7aa8c17fd7377610cdd8 ] As it is crypto_remove_spawn may try to unregister an instance which is yet to be registered. This patch fixes this by checking whether the instance has been registered before attempting to remove it. It also removes a bogus cra_destroy check in crypto_register_instance as 1) it's outside the mutex; 2) we have a check in __crypto_register_alg already. Signed-off-by: Herbert Xu Cc: David Miller Signed-off-by: Greg Kroah-Hartman --- crypto/algapi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/crypto/algapi.c +++ b/crypto/algapi.c @@ -98,6 +98,9 @@ static void crypto_remove_spawn(struct c return; inst->alg.cra_flags |= CRYPTO_ALG_DEAD; + if (hlist_unhashed(&inst->list)) + return; + if (!tmpl || !crypto_tmpl_get(tmpl)) return; @@ -333,9 +336,6 @@ int crypto_register_instance(struct cryp LIST_HEAD(list); int err = -EINVAL; - if (inst->alg.cra_destroy) - goto err; - err = crypto_check_alg(&inst->alg); if (err) goto err; -- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/