]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
crypto: xts,lrw - fix out-of-bounds write after kmalloc failure
authorEric Biggers <ebiggers@google.com>
Thu, 23 Mar 2017 20:39:46 +0000 (13:39 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 8 Apr 2017 07:35:07 +0000 (09:35 +0200)
commit9fef1e65279d60548190eda43a60ef69d5652373
tree5d720186b3c23c6c75d74156a63b5c195ebabf06
parent5a16448c2132469b7f4dfd26cacff8b313920ede
crypto: xts,lrw - fix out-of-bounds write after kmalloc failure

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.

Fixes: f1c131b45410 ("crypto: xts - Convert to skcipher")
Fixes: 700cb3f5fe75 ("crypto: lrw - Convert to skcipher")
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
crypto/lrw.c
crypto/xts.c