Skip to content

Commit 0ae4524

Browse files
committed
Merge tag 'v6.18-p3' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto fixes from Herbert Xu: - Fix bug in crypto_skcipher that breaks the new ti driver - Check for invalid assoclen in essiv * tag 'v6.18-p3' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: crypto: essiv - Check ssize for decryption and in-place encryption crypto: skcipher - Fix reqsize handling
2 parents 84d4e8b + 6bb73db commit 0ae4524

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

crypto/essiv.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,14 @@ static int essiv_aead_crypt(struct aead_request *req, bool enc)
186186
const struct essiv_tfm_ctx *tctx = crypto_aead_ctx(tfm);
187187
struct essiv_aead_request_ctx *rctx = aead_request_ctx(req);
188188
struct aead_request *subreq = &rctx->aead_req;
189+
int ivsize = crypto_aead_ivsize(tfm);
190+
int ssize = req->assoclen - ivsize;
189191
struct scatterlist *src = req->src;
190192
int err;
191193

194+
if (ssize < 0)
195+
return -EINVAL;
196+
192197
crypto_cipher_encrypt_one(tctx->essiv_cipher, req->iv, req->iv);
193198

194199
/*
@@ -198,19 +203,12 @@ static int essiv_aead_crypt(struct aead_request *req, bool enc)
198203
*/
199204
rctx->assoc = NULL;
200205
if (req->src == req->dst || !enc) {
201-
scatterwalk_map_and_copy(req->iv, req->dst,
202-
req->assoclen - crypto_aead_ivsize(tfm),
203-
crypto_aead_ivsize(tfm), 1);
206+
scatterwalk_map_and_copy(req->iv, req->dst, ssize, ivsize, 1);
204207
} else {
205208
u8 *iv = (u8 *)aead_request_ctx(req) + tctx->ivoffset;
206-
int ivsize = crypto_aead_ivsize(tfm);
207-
int ssize = req->assoclen - ivsize;
208209
struct scatterlist *sg;
209210
int nents;
210211

211-
if (ssize < 0)
212-
return -EINVAL;
213-
214212
nents = sg_nents_for_len(req->src, ssize);
215213
if (nents < 0)
216214
return -EINVAL;

crypto/skcipher.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,8 @@ static int crypto_skcipher_init_tfm(struct crypto_tfm *tfm)
294294
return crypto_init_lskcipher_ops_sg(tfm);
295295
}
296296

297+
crypto_skcipher_set_reqsize(skcipher, crypto_tfm_alg_reqsize(tfm));
298+
297299
if (alg->exit)
298300
skcipher->base.exit = crypto_skcipher_exit_tfm;
299301

0 commit comments

Comments
 (0)