Skip to content

Commit

Permalink
crypto: ahash - ensure statesize is non-zero
Browse files Browse the repository at this point in the history
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: [email protected]
Signed-off-by: Russell King <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
Russell King authored and herbertx committed Oct 13, 2015
1 parent 92b2790 commit 8996eaf
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crypto/ahash.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,8 @@ static int ahash_prepare_alg(struct ahash_alg *alg)
struct crypto_alg *base = &alg->halg.base;

if (alg->halg.digestsize > PAGE_SIZE / 8 ||
alg->halg.statesize > PAGE_SIZE / 8)
alg->halg.statesize > PAGE_SIZE / 8 ||
alg->halg.statesize == 0)
return -EINVAL;

base->cra_type = &crypto_ahash_type;
Expand Down

0 comments on commit 8996eaf

Please sign in to comment.