<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 28, 2016 at 6:18 PM, Jonas Eymann <span dir="ltr"><<a href="mailto:J.Eymann@gmx.net" target="_blank">J.Eymann@gmx.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Alexandru,<br>
<div><div class="h5"><br>
><br>
> Crypto hash algorithms must provide the statesize for<br>
> kernel 4.2+<br>
><br>
> Referencing commit in the kernel:<br>
><br>
> commit 8996eafdcbad149ac0f772fb1649fbb75c482a6a<br>
> Author: Russell King <<a href="mailto:rmk%2Bkernel@arm.linux.org.uk">rmk+kernel@arm.linux.org.uk</a>><br>
> Date:   Fri Oct 9 20:43:33 2015 +0100<br>
><br>
>     crypto: ahash - ensure statesize is non-zero<br>
><br>
>     Unlike shash algorithms, ahash drivers must implement export<br>
>     and import as their descriptors may contain hardware state and<br>
>     cannot be exported as is.  Unfortunately some ahash drivers did<br>
>     not provide them and end up causing crashes with algif_hash.<br>
><br>
>     This patch adds a check to prevent these drivers from registering<br>
>     ahash algorithms until they are fixed.<br>
><br>
>     Cc: <a href="mailto:stable@vger.kernel.org">stable@vger.kernel.org</a><br>
>     Signed-off-by: Russell King <<a href="mailto:rmk%2Bkernel@arm.linux.org.uk">rmk+kernel@arm.linux.org.uk</a>><br>
>     Signed-off-by: Herbert Xu <<a href="mailto:herbert@gondor.apana.org.au">herbert@gondor.apana.org.au</a>><br>
><br>
> Signed-off-by: Alexandru Ardelean <<a href="mailto:ardeleanalex@gmail.com">ardeleanalex@gmail.com</a>><br>
> ---<br>
>  .../302-add-statesize-to-talitos-crypto-driver.sh  | 100 +++++++++++++++++++++<br>
>  1 file changed, 100 insertions(+)<br>
>  create mode 100644 target/linux/mpc85xx/patches-4.4/302-add-statesize-to-talitos-crypto-driver.sh<br>
><br>
> 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<br>
> new file mode 100644<br>
> index 0000000..4d77c19<br>
> --- /dev/null<br>
> +++ b/target/linux/mpc85xx/patches-4.4/302-add-statesize-to-talitos-crypto-driver.sh<br>
> @@ -0,0 +1,100 @@<br>
> +diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c<br>
> +index b6f9f42..b786b21 100644<br>
> +--- a/drivers/crypto/talitos.c<br>
> ++++ b/drivers/crypto/talitos.c<br>
> +@@ -2334,6 +2334,7 @@ static struct talitos_alg_template driver_algs[] = {<br>
> +     {       .type = CRYPTO_ALG_TYPE_AHASH,<br>
> +             .alg.hash = {<br>
> +                     .halg.digestsize = MD5_DIGEST_SIZE,<br>
> ++                    .halg.statesize  = sizeof(struct talitos_ahash_req_ctx),<br>
> +                     .halg.base = {<br>
> +                             .cra_name = "md5",<br>
> +                             .cra_driver_name = "md5-talitos",<br>
> +@@ -2349,6 +2350,7 @@ static struct talitos_alg_template driver_algs[] = {<br>
> +     {       .type = CRYPTO_ALG_TYPE_AHASH,<br>
> +             .alg.hash = {<br>
> +                     .halg.digestsize = SHA1_DIGEST_SIZE,<br>
> ++                    .halg.statesize  = sizeof(struct talitos_ahash_req_ctx),<br>
> +                     .halg.base = {<br>
> +                             .cra_name = "sha1",<br>
> +                             .cra_driver_name = "sha1-talitos",<br>
> +@@ -2364,6 +2366,7 @@ static struct talitos_alg_template driver_algs[] = {<br>
> +     {       .type = CRYPTO_ALG_TYPE_AHASH,<br>
> +             .alg.hash = {<br>
> +                     .halg.digestsize = SHA224_DIGEST_SIZE,<br>
> ++                    .halg.statesize  = sizeof(struct talitos_ahash_req_ctx),<br>
> +                     .halg.base = {<br>
> +                             .cra_name = "sha224",<br>
> +                             .cra_driver_name = "sha224-talitos",<br>
> +@@ -2379,6 +2382,7 @@ static struct talitos_alg_template driver_algs[] = {<br>
> +     {       .type = CRYPTO_ALG_TYPE_AHASH,<br>
> +             .alg.hash = {<br>
> +                     .halg.digestsize = SHA256_DIGEST_SIZE,<br>
> ++                    .halg.statesize  = sizeof(struct talitos_ahash_req_ctx),<br>
> +                     .halg.base = {<br>
> +                             .cra_name = "sha256",<br>
> +                             .cra_driver_name = "sha256-talitos",<br>
> +@@ -2394,6 +2398,7 @@ static struct talitos_alg_template driver_algs[] = {<br>
> +     {       .type = CRYPTO_ALG_TYPE_AHASH,<br>
> +             .alg.hash = {<br>
> +                     .halg.digestsize = SHA384_DIGEST_SIZE,<br>
> ++                    .halg.statesize  = sizeof(struct talitos_ahash_req_ctx),<br>
> +                     .halg.base = {<br>
> +                             .cra_name = "sha384",<br>
> +                             .cra_driver_name = "sha384-talitos",<br>
> +@@ -2409,6 +2414,7 @@ static struct talitos_alg_template driver_algs[] = {<br>
> +     {       .type = CRYPTO_ALG_TYPE_AHASH,<br>
> +             .alg.hash = {<br>
> +                     .halg.digestsize = SHA512_DIGEST_SIZE,<br>
> ++                    .halg.statesize  = sizeof(struct talitos_ahash_req_ctx),<br>
> +                     .halg.base = {<br>
> +                             .cra_name = "sha512",<br>
> +                             .cra_driver_name = "sha512-talitos",<br>
> +@@ -2424,6 +2430,7 @@ static struct talitos_alg_template driver_algs[] = {<br>
> +     {       .type = CRYPTO_ALG_TYPE_AHASH,<br>
> +             .alg.hash = {<br>
> +                     .halg.digestsize = MD5_DIGEST_SIZE,<br>
> ++                    .halg.statesize  = sizeof(struct talitos_ahash_req_ctx),<br>
> +                     .halg.base = {<br>
> +                             .cra_name = "hmac(md5)",<br>
> +                             .cra_driver_name = "hmac-md5-talitos",<br>
> +@@ -2439,6 +2446,7 @@ static struct talitos_alg_template driver_algs[] = {<br>
> +     {       .type = CRYPTO_ALG_TYPE_AHASH,<br>
> +             .alg.hash = {<br>
> +                     .halg.digestsize = SHA1_DIGEST_SIZE,<br>
> ++                    .halg.statesize  = sizeof(struct talitos_ahash_req_ctx),<br>
> +                     .halg.base = {<br>
> +                             .cra_name = "hmac(sha1)",<br>
> +                             .cra_driver_name = "hmac-sha1-talitos",<br>
> +@@ -2454,6 +2462,7 @@ static struct talitos_alg_template driver_algs[] = {<br>
> +     {       .type = CRYPTO_ALG_TYPE_AHASH,<br>
> +             .alg.hash = {<br>
> +                     .halg.digestsize = SHA224_DIGEST_SIZE,<br>
> ++                    .halg.statesize  = sizeof(struct talitos_ahash_req_ctx),<br>
> +                     .halg.base = {<br>
> +                             .cra_name = "hmac(sha224)",<br>
> +                             .cra_driver_name = "hmac-sha224-talitos",<br>
> +@@ -2469,6 +2478,7 @@ static struct talitos_alg_template driver_algs[] = {<br>
> +     {       .type = CRYPTO_ALG_TYPE_AHASH,<br>
> +             .alg.hash = {<br>
> +                     .halg.digestsize = SHA256_DIGEST_SIZE,<br>
> ++                    .halg.statesize  = sizeof(struct talitos_ahash_req_ctx),<br>
> +                     .halg.base = {<br>
> +                             .cra_name = "hmac(sha256)",<br>
> +                             .cra_driver_name = "hmac-sha256-talitos",<br>
> +@@ -2484,6 +2494,7 @@ static struct talitos_alg_template driver_algs[] = {<br>
> +     {       .type = CRYPTO_ALG_TYPE_AHASH,<br>
> +             .alg.hash = {<br>
> +                     .halg.digestsize = SHA384_DIGEST_SIZE,<br>
> ++                    .halg.statesize  = sizeof(struct talitos_ahash_req_ctx),<br>
> +                     .halg.base = {<br>
> +                             .cra_name = "hmac(sha384)",<br>
> +                             .cra_driver_name = "hmac-sha384-talitos",<br>
> +@@ -2499,6 +2510,7 @@ static struct talitos_alg_template driver_algs[] = {<br>
> +     {       .type = CRYPTO_ALG_TYPE_AHASH,<br>
> +             .alg.hash = {<br>
> +                     .halg.digestsize = SHA512_DIGEST_SIZE,<br>
> ++                    .halg.statesize  = sizeof(struct talitos_ahash_req_ctx),<br>
> +                     .halg.base = {<br>
> +                             .cra_name = "hmac(sha512)",<br>
> +                             .cra_driver_name = "hmac-sha512-talitos",<br>
> --<br>
> 2.8.1<br>
</div></div>> _______________________________________________<br>
> openwrt-devel mailing list<br>
> <a href="mailto:openwrt-devel@lists.openwrt.org">openwrt-devel@lists.openwrt.org</a><br>
> <a href="https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel" rel="noreferrer" target="_blank">https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel</a><br>
><br>
<br>
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<br>
3639ca840df953f9af6f15fc8a6bf77f19075ab1. It assume it will be merged to the mainline kernel in the next merge window.<br>
<span class="HOEnZb"><font color="#888888"><br>
Jonas<br>
</font></span></blockquote></div><br></div><div class="gmail_extra">Thanks for the heads-up Jonas.<br></div><div class="gmail_extra">Seems I was a bit naive ; I just modified the driver this and it built fine.<br></div><div class="gmail_extra">I'll take a look there and try to backport the patch.<br><br></div><div class="gmail_extra">I'll submit it to the OpenWrt list.<br></div><div class="gmail_extra">At the moment I'm in the midst of sync-ing our tree with OpenWrt trunk and plenty of stuff needs re-sync-ing.</div><div class="gmail_extra"><br></div></div>