Skip to content

Commit e326df5

Browse files
committed
Merge tag 'v6.8-p5' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto fixes from Herbert Xu: "This fixes a regression in lskcipher and an out-of-bound access in arm64/neonbs" * tag 'v6.8-p5' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: crypto: arm64/neonbs - fix out-of-bounds access on short input crypto: lskcipher - Copy IV in lskcipher glue code always
2 parents cf11829 + 1c0cf6d commit e326df5

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

arch/arm64/crypto/aes-neonbs-glue.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,19 @@ static int ctr_encrypt(struct skcipher_request *req)
227227
src += blocks * AES_BLOCK_SIZE;
228228
}
229229
if (nbytes && walk.nbytes == walk.total) {
230+
u8 buf[AES_BLOCK_SIZE];
231+
u8 *d = dst;
232+
233+
if (unlikely(nbytes < AES_BLOCK_SIZE))
234+
src = dst = memcpy(buf + sizeof(buf) - nbytes,
235+
src, nbytes);
236+
230237
neon_aes_ctr_encrypt(dst, src, ctx->enc, ctx->key.rounds,
231238
nbytes, walk.iv);
239+
240+
if (unlikely(nbytes < AES_BLOCK_SIZE))
241+
memcpy(d, dst, nbytes);
242+
232243
nbytes = 0;
233244
}
234245
kernel_neon_end();

crypto/lskcipher.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,12 @@ static int crypto_lskcipher_crypt_sg(struct skcipher_request *req,
212212

213213
ivsize = crypto_lskcipher_ivsize(tfm);
214214
ivs = PTR_ALIGN(ivs, crypto_skcipher_alignmask(skcipher) + 1);
215+
memcpy(ivs, req->iv, ivsize);
215216

216217
flags = req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP;
217218

218219
if (req->base.flags & CRYPTO_SKCIPHER_REQ_CONT)
219220
flags |= CRYPTO_LSKCIPHER_FLAG_CONT;
220-
else
221-
memcpy(ivs, req->iv, ivsize);
222221

223222
if (!(req->base.flags & CRYPTO_SKCIPHER_REQ_NOTFINAL))
224223
flags |= CRYPTO_LSKCIPHER_FLAG_FINAL;
@@ -234,8 +233,7 @@ static int crypto_lskcipher_crypt_sg(struct skcipher_request *req,
234233
flags |= CRYPTO_LSKCIPHER_FLAG_CONT;
235234
}
236235

237-
if (flags & CRYPTO_LSKCIPHER_FLAG_FINAL)
238-
memcpy(req->iv, ivs, ivsize);
236+
memcpy(req->iv, ivs, ivsize);
239237

240238
return err;
241239
}

0 commit comments

Comments
 (0)