Commit 78ecd7a9 authored by Herbert Xu's avatar Herbert Xu Committed by Greg Kroah-Hartman

crypto: authenc - Avoid using clobbered request pointer

crypto: authenc - Avoid using clobbered request pointer

[ Upstream commit: a697690b ]

Authenc works in two stages for encryption, it first encrypts and
then computes an ICV.  The context memory of the request is used
by both operations.  The problem is that when an asynchronous
encryption completes, we will compute the ICV and then reread the
context memory of the encryption to get the original request.

It just happens that we have a buffer of 16 bytes in front of the
request pointer, so ICVs of 16 bytes (such as SHA1) do not trigger
the bug.  However, any attempt to uses a larger ICV instantly kills
the machine when the first asynchronous encryption is completed.

This patch fixes this by saving the request pointer before we start
the ICV computation.
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent c5b15cb1
...@@ -174,8 +174,9 @@ static int crypto_authenc_genicv(struct aead_request *req, u8 *iv, ...@@ -174,8 +174,9 @@ static int crypto_authenc_genicv(struct aead_request *req, u8 *iv,
static void crypto_authenc_encrypt_done(struct crypto_async_request *req, static void crypto_authenc_encrypt_done(struct crypto_async_request *req,
int err) int err)
{ {
if (!err) {
struct aead_request *areq = req->data; struct aead_request *areq = req->data;
if (!err) {
struct crypto_aead *authenc = crypto_aead_reqtfm(areq); struct crypto_aead *authenc = crypto_aead_reqtfm(areq);
struct crypto_authenc_ctx *ctx = crypto_aead_ctx(authenc); struct crypto_authenc_ctx *ctx = crypto_aead_ctx(authenc);
struct ablkcipher_request *abreq = aead_request_ctx(areq); struct ablkcipher_request *abreq = aead_request_ctx(areq);
...@@ -185,7 +186,7 @@ static void crypto_authenc_encrypt_done(struct crypto_async_request *req, ...@@ -185,7 +186,7 @@ static void crypto_authenc_encrypt_done(struct crypto_async_request *req,
err = crypto_authenc_genicv(areq, iv, 0); err = crypto_authenc_genicv(areq, iv, 0);
} }
aead_request_complete(req->data, err); aead_request_complete(areq, err);
} }
static int crypto_authenc_encrypt(struct aead_request *req) static int crypto_authenc_encrypt(struct aead_request *req)
...@@ -216,14 +217,15 @@ static int crypto_authenc_encrypt(struct aead_request *req) ...@@ -216,14 +217,15 @@ static int crypto_authenc_encrypt(struct aead_request *req)
static void crypto_authenc_givencrypt_done(struct crypto_async_request *req, static void crypto_authenc_givencrypt_done(struct crypto_async_request *req,
int err) int err)
{ {
if (!err) {
struct aead_request *areq = req->data; struct aead_request *areq = req->data;
if (!err) {
struct skcipher_givcrypt_request *greq = aead_request_ctx(areq); struct skcipher_givcrypt_request *greq = aead_request_ctx(areq);
err = crypto_authenc_genicv(areq, greq->giv, 0); err = crypto_authenc_genicv(areq, greq->giv, 0);
} }
aead_request_complete(req->data, err); aead_request_complete(areq, err);
} }
static int crypto_authenc_givencrypt(struct aead_givcrypt_request *req) static int crypto_authenc_givencrypt(struct aead_givcrypt_request *req)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment