Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: s390/aes - Fix buffer overread in CTR mode

When processing the last block, the s390 ctr code will always read
a whole block, even if there isn't a whole block of data left. Fix
this by using the actual length left and copy it into a buffer first
for processing.

Fixes: 0200f3ecc196 ("crypto: s390 - add System z hardware support for CTR mode")
Cc: <stable@vger.kernel.org>
Reported-by: Guangwu Zhang <guazhang@redhat.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Reviewd-by: Harald Freudenberger <freude@de.ibm.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

+6 -2
+3 -1
arch/s390/crypto/aes_s390.c
··· 597 597 * final block may be < AES_BLOCK_SIZE, copy only nbytes 598 598 */ 599 599 if (nbytes) { 600 - cpacf_kmctr(sctx->fc, sctx->key, buf, walk.src.virt.addr, 600 + memset(buf, 0, AES_BLOCK_SIZE); 601 + memcpy(buf, walk.src.virt.addr, nbytes); 602 + cpacf_kmctr(sctx->fc, sctx->key, buf, buf, 601 603 AES_BLOCK_SIZE, walk.iv); 602 604 memcpy(walk.dst.virt.addr, buf, nbytes); 603 605 crypto_inc(walk.iv, AES_BLOCK_SIZE);
+3 -1
arch/s390/crypto/paes_s390.c
··· 693 693 * final block may be < AES_BLOCK_SIZE, copy only nbytes 694 694 */ 695 695 if (nbytes) { 696 + memset(buf, 0, AES_BLOCK_SIZE); 697 + memcpy(buf, walk.src.virt.addr, nbytes); 696 698 while (1) { 697 699 if (cpacf_kmctr(ctx->fc, &param, buf, 698 - walk.src.virt.addr, AES_BLOCK_SIZE, 700 + buf, AES_BLOCK_SIZE, 699 701 walk.iv) == AES_BLOCK_SIZE) 700 702 break; 701 703 if (__paes_convert_key(ctx))