FAILED: patch "[PATCH] crypto: stm32/crc32 - Fix kernel BUG triggered in probe()" failed to apply to 4.19-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 4.19-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 29009604ad4e3ef784fd9b9fef6f23610ddf633d Mon Sep 17 00:00:00 2001
From: Marek Vasut <[email protected]>
Date: Mon, 20 Dec 2021 20:50:22 +0100
Subject: [PATCH] crypto: stm32/crc32 - Fix kernel BUG triggered in probe()
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.
drivers/crypto/stm32/stm32-crc32.c +2 -2
@@ -279,7 +279,7 @@ static struct shash_alg algs[] = { .digestsize = CHKSUM_DIGEST_SIZE, .base = { .cra_name = "crc32", - .cra_driver_name = DRIVER_NAME, + .cra_driver_name = "stm32-crc32-crc32", .cra_priority = 200, .cra_flags = CRYPTO_ALG_OPTIONAL_KEY, .cra_blocksize = CHKSUM_BLOCK_SIZE,
@@ -301,7 +301,7 @@ static struct shash_alg algs[] = { .digestsize = CHKSUM_DIGEST_SIZE, .base = { .cra_name = "crc32c", - .cra_driver_name = DRIVER_NAME, + .cra_driver_name = "stm32-crc32-crc32c", .cra_priority = 200, .cra_flags = CRYPTO_ALG_OPTIONAL_KEY, .cra_blocksize = CHKSUM_BLOCK_SIZE,
PATCH 1/1 crypto: stm32/crc32 - Fix kernel BUG triggered in probe()
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.
---
Backport on 4.19.225, likely works on 4.14 too. The patch likely failed to apply because the hit 5.3:fdbd643a74efb ("crypto: stm32/crc32 - rename driver file") and renamed drivers/crypto/stm32/stm32{-,_}crc32.c
--- drivers/crypto/stm32/stm32_crc32.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/stm32/stm32_crc32.c +2 -2
@@ -230,7 +230,7 @@ static struct shash_alg algs[] = { .digestsize = CHKSUM_DIGEST_SIZE, .base = { .cra_name = "crc32", - .cra_driver_name = DRIVER_NAME, + .cra_driver_name = "stm32-crc32-crc32", .cra_priority = 200, .cra_flags = CRYPTO_ALG_OPTIONAL_KEY, .cra_blocksize = CHKSUM_BLOCK_SIZE,
@@ -252,7 +252,7 @@ static struct shash_alg algs[] = { .digestsize = CHKSUM_DIGEST_SIZE, .base = { .cra_name = "crc32c", - .cra_driver_name = DRIVER_NAME, + .cra_driver_name = "stm32-crc32-crc32c", .cra_priority = 200, .cra_flags = CRYPTO_ALG_OPTIONAL_KEY, .cra_blocksize = CHKSUM_BLOCK_SIZE,
Signature · 1 line
2.34.1
Re: [PATCH] crypto: stm32/crc32 - Fix kernel BUG triggered in probe()
Quoted 30 lines · Marek Vasut
The
include/linux/crypto.hstructcrypto_algfieldcra_driver_namedescription 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_nameis 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 uniquecra_driver_nameto each registered transformation provider.The kernel crash is triggered when the driver calls
crypto_register_shashes()which callscrypto_register_shash(), which callscrypto_register_alg(), which calls__crypto_register_alg(), which returns-EEXIST, which is propagated back through this call chain. Upon-EEXISTfromcrypto_register_shash(), thecrypto_register_shashes()starts unregistering the providers back, and callscrypto_unregister_shash(), which callscrypto_unregister_alg(), and this is where theBUG()triggers due to incorrectcra_refcnt.Fixes b51dbe90912a ("crypto: stm32 - Support for STM32 CRC32 crypto module")Signed-off-by Marek Vasut <[email protected]>Cc <[email protected]> # 4.12+Cc Alexandre Torgue <[email protected]>Cc Fabien Dessenne <[email protected]>Cc Herbert Xu <[email protected]>Cc Lionel Debieve <[email protected]>Cc Nicolas Toromanoff <[email protected]>Signed-off-by Herbert Xu <[email protected]>
Quoted 8 lines
---
Backport on 4.19.225, likely works on 4.14 too. The patch likely failed to apply because the hit 5.3:fdbd643a74efb("crypto: stm32/crc32 - rename driver file") and renameddrivers/crypto/stm32/stm32{-,_}crc32.c--- drivers/crypto/stm32/stm32_crc32.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Now queued up, thanks.
greg k-h