Patch "crypto: xts,lrw - fix out-of-bounds write after kmalloc failure" has been added to the 4.10-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
crypto: xts,lrw - fix out-of-bounds write after kmalloc failure
to the 4.10-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
crypto-xts-lrw-fix-out-of-bounds-write-after-kmalloc-failure.patch
and it can be found in the queue-4.10 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
9df0eb180c2074451f25556eb566d89c7057c2acMon Sep 17 00:00:00 2001
From: Eric Biggers <[email protected]>
Date: Thu, 23 Mar 2017 13:39:46 -0700
Subject: crypto: xts,lrw - fix out-of-bounds write after kmalloc failure
From: Eric Biggers <[email protected]>
commit 9df0eb180c2074451f25556eb566d89c7057c2ac upstream.
In the generic XTS and LRW algorithms, for input data > 128 bytes, a temporary buffer is allocated to hold the values to be XOR'ed with the data before and after encryption or decryption. If the allocation fails, the fixed-size buffer embedded in the request buffer is meant to be used as a fallback --- resulting in more calls to the ECB algorithm, but still producing the correct result. However, we weren't correctly limiting subreq->cryptlen in this case, resulting in pre_crypt() overrunning the embedded buffer. Fix this by setting subreq->cryptlen correctly.
--- crypto/lrw.c | 7 +++++-- crypto/xts.c | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-)
crypto/lrw.c +5 -2
@@ -286,8 +286,11 @@ static int init_crypt(struct skcipher_re subreq->cryptlen =LRW_BUFFER_SIZE ;if (req->cryptlen >LRW_BUFFER_SIZE ) { - subreq->cryptlen =min (req->cryptlen, (unsigned )PAGE_SIZE ); - rctx->ext =kmalloc (subreq->cryptlen, gfp); +unsigned int n =min (req->cryptlen, (unsigned int )PAGE_SIZE ); + + rctx->ext =kmalloc (n, gfp); +if (rctx->ext) + subreq->cryptlen = n; } rctx->src = req->src;
crypto/xts.c +5 -2
@@ -230,8 +230,11 @@ static int init_crypt(struct skcipher_re subreq->cryptlen =XTS_BUFFER_SIZE ;if (req->cryptlen >XTS_BUFFER_SIZE ) { - subreq->cryptlen =min (req->cryptlen, (unsigned )PAGE_SIZE ); - rctx->ext =kmalloc (subreq->cryptlen, gfp); +unsigned int n =min (req->cryptlen, (unsigned int )PAGE_SIZE ); + + rctx->ext =kmalloc (n, gfp); +if (rctx->ext) + subreq->cryptlen = n; } rctx->src = req->src;
Patches currently in stable-queue which might be from [email protected] are
queue-4.10/crypto-xts-lrw-fix-out-of-bounds-write-after-kmalloc-failure.patch