Skip to content

Commit

Permalink
[CRYPTO] Check cra_alignmask against cra_blocksize
Browse files Browse the repository at this point in the history
The cipher code relies on the fact that the block size is a multiple
of the required alignment.  So we should check this at the time of
algorith registration.  We also ensure that the block size is bounded
by the page size.

Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
herbertx committed Oct 30, 2005
1 parent 6df5b9f commit 1b40efd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion crypto/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,10 @@ int crypto_register_alg(struct crypto_alg *alg)
if (alg->cra_alignmask & (alg->cra_alignmask + 1))
return -EINVAL;

if (alg->cra_alignmask > PAGE_SIZE)
if (alg->cra_alignmask & alg->cra_blocksize)
return -EINVAL;

if (alg->cra_blocksize > PAGE_SIZE)
return -EINVAL;

down_write(&crypto_alg_sem);
Expand Down

0 comments on commit 1b40efd

Please sign in to comment.