Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6FCEEC433F5 for ; Fri, 31 Dec 2021 11:34:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229545AbhLaLev (ORCPT ); Fri, 31 Dec 2021 06:34:51 -0500 Received: from helcar.hmeau.com ([216.24.177.18]:58788 "EHLO fornost.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229457AbhLaLev (ORCPT ); Fri, 31 Dec 2021 06:34:51 -0500 Received: from gwarestrin.arnor.me.apana.org.au ([192.168.103.7]) by fornost.hmeau.com with smtp (Exim 4.92 #5 (Debian)) id 1n3GBG-0004se-P3; Fri, 31 Dec 2021 22:34:43 +1100 Received: by gwarestrin.arnor.me.apana.org.au (sSMTP sendmail emulation); Fri, 31 Dec 2021 22:34:42 +1100 Date: Fri, 31 Dec 2021 22:34:42 +1100 From: Herbert Xu To: Marek Vasut Cc: linux-crypto@vger.kernel.org, stable@vger.kernel.org, Alexandre Torgue , Fabien Dessenne , Lionel Debieve , Nicolas Toromanoff , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com Subject: Re: [PATCH] crypto: stm32/crc32 - Fix kernel BUG triggered in probe() Message-ID: References: <20211220195022.1387104-1-marex@denx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211220195022.1387104-1-marex@denx.de> Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Mon, Dec 20, 2021 at 08:50:22PM +0100, Marek Vasut wrote: > The include/linux/crypto.h struct crypto_alg field cra_driver_name description > states "Unique name of the transformation provider. " ... " this contains the > name of the chip or provider and the name of the transformation algorithm." > > In case of the stm32-crc driver, field cra_driver_name is identical for all > registered transformation providers and set to the name of the driver itself, > which is incorrect. This patch fixes it by assigning a unique cra_driver_name > to each registered transformation provider. > > The kernel crash is triggered when the driver calls crypto_register_shashes() > which calls crypto_register_shash(), which calls crypto_register_alg(), which > calls __crypto_register_alg(), which returns -EEXIST, which is propagated > back through this call chain. Upon -EEXIST from crypto_register_shash(), the > crypto_register_shashes() starts unregistering the providers back, and calls > crypto_unregister_shash(), which calls crypto_unregister_alg(), and this is > where the BUG() triggers due to incorrect cra_refcnt. > > Fixes: b51dbe90912a ("crypto: stm32 - Support for STM32 CRC32 crypto module") > Signed-off-by: Marek Vasut > Cc: # 4.12+ > Cc: Alexandre Torgue > Cc: Fabien Dessenne > Cc: Herbert Xu > Cc: Lionel Debieve > Cc: Nicolas Toromanoff > Cc: linux-arm-kernel@lists.infradead.org > Cc: linux-stm32@st-md-mailman.stormreply.com > To: linux-crypto@vger.kernel.org > --- > drivers/crypto/stm32/stm32-crc32.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) Patch applied. Thanks. -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt