]> git.baikalelectronics.ru Git - kernel.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)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 24 Mar 2017 13:51:34 +0000 (21:51 +0800)
commit68ba9a5e56e4dcf3283b48dbe904eaa30fba805d
tree493dfd3286e9d96b9c9ae42956136a4e9a7b5fb9
parent612300c02714c9859d47096f0e3295908cac6b08
crypto: xts,lrw - fix out-of-bounds write after kmalloc failure

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: 2375da2442e6 ("crypto: xts - Convert to skcipher")
Fixes: b72811114139 ("crypto: lrw - Convert to skcipher")
Cc: stable@vger.kernel.org # v4.10+
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>
crypto/lrw.c
crypto/xts.c