[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ZbezZ/BV+DfMEEHB@gondor.apana.org.au>
Date: Mon, 29 Jan 2024 22:17:11 +0800
From: Herbert Xu <herbert@...dor.apana.org.au>
To: syzbot <syzbot+050eeedd6c285d8c42f2@...kaller.appspotmail.com>
Cc: davem@...emloft.net, linux-crypto@...r.kernel.org,
linux-kernel@...r.kernel.org, syzkaller-bugs@...glegroups.com
Subject: [PATCH] crypto: cbc - Ensure statesize is zero
On Mon, Jan 29, 2024 at 04:55:30AM -0800, syzbot wrote:
>
> HEAD commit: 3a5879d495b2 Merge tag 'ata-6.8-rc2' of git://git.kernel.o..
> git tree: upstream
> console+strace: https://syzkaller.appspot.com/x/log.txt?x=1683b6bbe80000
> kernel config: https://syzkaller.appspot.com/x/.config?x=bc36d99546fe9035
> dashboard link: https://syzkaller.appspot.com/bug?extid=050eeedd6c285d8c42f2
Thanks for the report. This is actually caused by the construction
of cbc(arc4), which wasn't possible previously. Let's make it
impossible again:
---8<---
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@...kaller.appspotmail.com
Fixes: 47309ea13591 ("crypto: arc4 - Add internal state")
Signed-off-by: Herbert Xu <herbert@...dor.apana.org.au>
diff --git a/crypto/cbc.c b/crypto/cbc.c
index eedddef9ce40..e81918ca68b7 100644
--- a/crypto/cbc.c
+++ b/crypto/cbc.c
@@ -148,6 +148,9 @@ static int crypto_cbc_create(struct crypto_template *tmpl, struct rtattr **tb)
if (!is_power_of_2(inst->alg.co.base.cra_blocksize))
goto out_free_inst;
+ if (inst->alg.co.statesize)
+ goto out_free_inst;
+
inst->alg.encrypt = crypto_cbc_encrypt;
inst->alg.decrypt = crypto_cbc_decrypt;
--
Email: Herbert Xu <herbert@...dor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Powered by blists - more mailing lists