crypto: skcipher - Pass statesize for simple lskcipher instances
authorHerbert Xu <herbert@gondor.apana.org.au>
Thu, 21 Dec 2023 02:42:57 +0000 (10:42 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 22 Dec 2023 04:30:19 +0000 (12:30 +0800)
When ecb is used to wrap an lskcipher, the statesize isn't set
correctly.  Fix this by making the simple instance creator set
the statesize.

Reported-by: syzbot+8ffb0839a24e9c6bfa76@syzkaller.appspotmail.com
Reported-by: Edward Adam Davis <eadavis@qq.com>
Fixes: 662ea18d089b ("crypto: skcipher - Make use of internal state")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/lskcipher.c

index a06008e112f319c91a3eae8cfb88e95509c4bb85..0b6dd8aa21f2edace686fb5531705698e7acc18d 100644 (file)
@@ -642,6 +642,7 @@ struct lskcipher_instance *lskcipher_alloc_instance_simple(
        inst->alg.co.min_keysize = cipher_alg->co.min_keysize;
        inst->alg.co.max_keysize = cipher_alg->co.max_keysize;
        inst->alg.co.ivsize = cipher_alg->co.base.cra_blocksize;
+       inst->alg.co.statesize = cipher_alg->co.statesize;
 
        /* Use struct crypto_lskcipher * by default, can be overridden */
        inst->alg.co.base.cra_ctxsize = sizeof(struct crypto_lskcipher *);