From 1b40efd772f4419fbc1a8940506424246985c333 Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Mon, 3 Oct 2005 15:15:36 +1000 Subject: [PATCH] [CRYPTO] Check cra_alignmask against cra_blocksize 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 --- crypto/api.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crypto/api.c b/crypto/api.c index 959c4e5f264f..40ae42e9b6a6 100644 --- a/crypto/api.c +++ b/crypto/api.c @@ -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); -- 2.30.2