[OpenWrt-Devel] [PATCH] target/linux/mpc85xx: fix talitos crypto driver init

Jonas Eymann J.Eymann at gmx.net
Thu Apr 28 11:18:45 EDT 2016


Hi Alexandru,

>
> Crypto hash algorithms must provide the statesize for
> kernel 4.2+
> 
> Referencing commit in the kernel:
> 
> commit 8996eafdcbad149ac0f772fb1649fbb75c482a6a
> Author: Russell King <rmk+kernel at arm.linux.org.uk>
> Date:   Fri Oct 9 20:43:33 2015 +0100
> 
>     crypto: ahash - ensure statesize is non-zero
> 
>     Unlike shash algorithms, ahash drivers must implement export
>     and import as their descriptors may contain hardware state and
>     cannot be exported as is.  Unfortunately some ahash drivers did
>     not provide them and end up causing crashes with algif_hash.
> 
>     This patch adds a check to prevent these drivers from registering
>     ahash algorithms until they are fixed.
> 
>     Cc: stable at vger.kernel.org
>     Signed-off-by: Russell King <rmk+kernel at arm.linux.org.uk>
>     Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au>
> 
> Signed-off-by: Alexandru Ardelean <ardeleanalex at gmail.com>
> ---
>  .../302-add-statesize-to-talitos-crypto-driver.sh  | 100 +++++++++++++++++++++
>  1 file changed, 100 insertions(+)
>  create mode 100644 target/linux/mpc85xx/patches-4.4/302-add-statesize-to-talitos-crypto-driver.sh
> 
> diff --git a/target/linux/mpc85xx/patches-4.4/302-add-statesize-to-talitos-crypto-driver.sh b/target/linux/mpc85xx/patches-4.4/302-add-statesize-to-talitos-crypto-driver.sh
> new file mode 100644
> index 0000000..4d77c19
> --- /dev/null
> +++ b/target/linux/mpc85xx/patches-4.4/302-add-statesize-to-talitos-crypto-driver.sh
> @@ -0,0 +1,100 @@
> +diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c
> +index b6f9f42..b786b21 100644
> +--- a/drivers/crypto/talitos.c
> ++++ b/drivers/crypto/talitos.c
> +@@ -2334,6 +2334,7 @@ static struct talitos_alg_template driver_algs[] = {
> + 	{	.type = CRYPTO_ALG_TYPE_AHASH,
> + 		.alg.hash = {
> + 			.halg.digestsize = MD5_DIGEST_SIZE,
> ++			.halg.statesize  = sizeof(struct talitos_ahash_req_ctx),
> + 			.halg.base = {
> + 				.cra_name = "md5",
> + 				.cra_driver_name = "md5-talitos",
> +@@ -2349,6 +2350,7 @@ static struct talitos_alg_template driver_algs[] = {
> + 	{	.type = CRYPTO_ALG_TYPE_AHASH,
> + 		.alg.hash = {
> + 			.halg.digestsize = SHA1_DIGEST_SIZE,
> ++			.halg.statesize  = sizeof(struct talitos_ahash_req_ctx),
> + 			.halg.base = {
> + 				.cra_name = "sha1",
> + 				.cra_driver_name = "sha1-talitos",
> +@@ -2364,6 +2366,7 @@ static struct talitos_alg_template driver_algs[] = {
> + 	{	.type = CRYPTO_ALG_TYPE_AHASH,
> + 		.alg.hash = {
> + 			.halg.digestsize = SHA224_DIGEST_SIZE,
> ++			.halg.statesize  = sizeof(struct talitos_ahash_req_ctx),
> + 			.halg.base = {
> + 				.cra_name = "sha224",
> + 				.cra_driver_name = "sha224-talitos",
> +@@ -2379,6 +2382,7 @@ static struct talitos_alg_template driver_algs[] = {
> + 	{	.type = CRYPTO_ALG_TYPE_AHASH,
> + 		.alg.hash = {
> + 			.halg.digestsize = SHA256_DIGEST_SIZE,
> ++			.halg.statesize  = sizeof(struct talitos_ahash_req_ctx),
> + 			.halg.base = {
> + 				.cra_name = "sha256",
> + 				.cra_driver_name = "sha256-talitos",
> +@@ -2394,6 +2398,7 @@ static struct talitos_alg_template driver_algs[] = {
> + 	{	.type = CRYPTO_ALG_TYPE_AHASH,
> + 		.alg.hash = {
> + 			.halg.digestsize = SHA384_DIGEST_SIZE,
> ++			.halg.statesize  = sizeof(struct talitos_ahash_req_ctx),
> + 			.halg.base = {
> + 				.cra_name = "sha384",
> + 				.cra_driver_name = "sha384-talitos",
> +@@ -2409,6 +2414,7 @@ static struct talitos_alg_template driver_algs[] = {
> + 	{	.type = CRYPTO_ALG_TYPE_AHASH,
> + 		.alg.hash = {
> + 			.halg.digestsize = SHA512_DIGEST_SIZE,
> ++			.halg.statesize  = sizeof(struct talitos_ahash_req_ctx),
> + 			.halg.base = {
> + 				.cra_name = "sha512",
> + 				.cra_driver_name = "sha512-talitos",
> +@@ -2424,6 +2430,7 @@ static struct talitos_alg_template driver_algs[] = {
> + 	{	.type = CRYPTO_ALG_TYPE_AHASH,
> + 		.alg.hash = {
> + 			.halg.digestsize = MD5_DIGEST_SIZE,
> ++			.halg.statesize  = sizeof(struct talitos_ahash_req_ctx),
> + 			.halg.base = {
> + 				.cra_name = "hmac(md5)",
> + 				.cra_driver_name = "hmac-md5-talitos",
> +@@ -2439,6 +2446,7 @@ static struct talitos_alg_template driver_algs[] = {
> + 	{	.type = CRYPTO_ALG_TYPE_AHASH,
> + 		.alg.hash = {
> + 			.halg.digestsize = SHA1_DIGEST_SIZE,
> ++			.halg.statesize  = sizeof(struct talitos_ahash_req_ctx),
> + 			.halg.base = {
> + 				.cra_name = "hmac(sha1)",
> + 				.cra_driver_name = "hmac-sha1-talitos",
> +@@ -2454,6 +2462,7 @@ static struct talitos_alg_template driver_algs[] = {
> + 	{	.type = CRYPTO_ALG_TYPE_AHASH,
> + 		.alg.hash = {
> + 			.halg.digestsize = SHA224_DIGEST_SIZE,
> ++			.halg.statesize  = sizeof(struct talitos_ahash_req_ctx),
> + 			.halg.base = {
> + 				.cra_name = "hmac(sha224)",
> + 				.cra_driver_name = "hmac-sha224-talitos",
> +@@ -2469,6 +2478,7 @@ static struct talitos_alg_template driver_algs[] = {
> + 	{	.type = CRYPTO_ALG_TYPE_AHASH,
> + 		.alg.hash = {
> + 			.halg.digestsize = SHA256_DIGEST_SIZE,
> ++			.halg.statesize  = sizeof(struct talitos_ahash_req_ctx),
> + 			.halg.base = {
> + 				.cra_name = "hmac(sha256)",
> + 				.cra_driver_name = "hmac-sha256-talitos",
> +@@ -2484,6 +2494,7 @@ static struct talitos_alg_template driver_algs[] = {
> + 	{	.type = CRYPTO_ALG_TYPE_AHASH,
> + 		.alg.hash = {
> + 			.halg.digestsize = SHA384_DIGEST_SIZE,
> ++			.halg.statesize  = sizeof(struct talitos_ahash_req_ctx),
> + 			.halg.base = {
> + 				.cra_name = "hmac(sha384)",
> + 				.cra_driver_name = "hmac-sha384-talitos",
> +@@ -2499,6 +2510,7 @@ static struct talitos_alg_template driver_algs[] = {
> + 	{	.type = CRYPTO_ALG_TYPE_AHASH,
> + 		.alg.hash = {
> + 			.halg.digestsize = SHA512_DIGEST_SIZE,
> ++			.halg.statesize  = sizeof(struct talitos_ahash_req_ctx),
> + 			.halg.base = {
> + 				.cra_name = "hmac(sha512)",
> + 				.cra_driver_name = "hmac-sha512-talitos",
> -- 
> 2.8.1
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
> 

AFAIK just setting the statesize is not sufficient as the driver also needs to implement the state import/export functions. However, this was implemented recently by Horia Geanta and already applied to cryptodev-2.6 as commit id
3639ca840df953f9af6f15fc8a6bf77f19075ab1. It assume it will be merged to the mainline kernel in the next merge window.

Jonas
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list