Skip to content

Commit 69fba37

Browse files
committed
crypto: cbc - Ensure statesize is zero
The cbc template should not be applied on stream ciphers, especially ones that have internal state. Enforce this by checking the state size when the instance is created. Reported-by: syzbot+050eeedd6c285d8c42f2@syzkaller.appspotmail.com Fixes: 47309ea ("crypto: arc4 - Add internal state") Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent ccb88e9 commit 69fba37

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

crypto/cbc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ static int crypto_cbc_create(struct crypto_template *tmpl, struct rtattr **tb)
148148
if (!is_power_of_2(inst->alg.co.base.cra_blocksize))
149149
goto out_free_inst;
150150

151+
if (inst->alg.co.statesize)
152+
goto out_free_inst;
153+
151154
inst->alg.encrypt = crypto_cbc_encrypt;
152155
inst->alg.decrypt = crypto_cbc_decrypt;
153156

0 commit comments

Comments
 (0)