crypto: authenc - Avoid using clobbered request pointer

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: Herbert Xu <herbert@gondor.apana.org.au>

+6 -4
+6 -4
crypto/authenc.c
··· 174 174 static void crypto_authenc_encrypt_done(struct crypto_async_request *req, 175 175 int err) 176 176 { 177 + struct aead_request *areq = req->data; 178 + 177 179 if (!err) { 178 - struct aead_request *areq = req->data; 179 180 struct crypto_aead *authenc = crypto_aead_reqtfm(areq); 180 181 struct crypto_authenc_ctx *ctx = crypto_aead_ctx(authenc); 181 182 struct ablkcipher_request *abreq = aead_request_ctx(areq); ··· 186 185 err = crypto_authenc_genicv(areq, iv, 0); 187 186 } 188 187 189 - aead_request_complete(req->data, err); 188 + aead_request_complete(areq, err); 190 189 } 191 190 192 191 static int crypto_authenc_encrypt(struct aead_request *req) ··· 217 216 static void crypto_authenc_givencrypt_done(struct crypto_async_request *req, 218 217 int err) 219 218 { 219 + struct aead_request *areq = req->data; 220 + 220 221 if (!err) { 221 - struct aead_request *areq = req->data; 222 222 struct skcipher_givcrypt_request *greq = aead_request_ctx(areq); 223 223 224 224 err = crypto_authenc_genicv(areq, greq->giv, 0); 225 225 } 226 226 227 - aead_request_complete(req->data, err); 227 + aead_request_complete(areq, err); 228 228 } 229 229 230 230 static int crypto_authenc_givencrypt(struct aead_givcrypt_request *req)