dm-crypt: Fix a bug of async cryption complete function
(resend, forgot cc: dm-devel for properly queue in patchwork)
-------- Original Message --------
Subject: Re: [BUGFIX] dm-crypt: Fix a bug of async cryption complete function
Date: Fri, 27 Feb 2009 14:51:15 +0100
From: Milan Broz <mbroz@redhat.com>
To: Herbert Xu <herbert@gondor.apana.org.au>, Alasdair G Kergon <agk@redhat.com>
CC: Huang Ying <ying.huang@intel.com>, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org
References: <1235724971.6204.106.camel@yhuang-dev.sh.intel.com> <20090227114103.GB24024@gondor.apana.org.au> <49A7D3E5.5040706@redhat.com> <20090227115638.GA24221@gondor.apana.org.au> <49A7DC7E.1040307@redhat.com> <20090227124602.GA24630@gondor.apana.org.au>
Herbert Xu wrote:
> On Fri, Feb 27, 2009 at 01:28:46PM +0100, Milan Broz wrote:
>> Like this?
>>
>> struct ablkcipher_request *req = (char *)dmreq - cc->dmreq_start;
>> mempool_free(req, cc->req_pool);
>
> Exactly. You could also embed the ablkcipher_request at the
> end of dmreq, as in
>
> struct dm_crypt_request {
> struct scatterlist sg_in;
> struct scatterlist sg_out;
> struct ablkcipher_request req;
> };
>
> Then you can use container_of.
Hm, I better keep explicitly this pointer retyping as reminder that
the structures need some revision in future...
Is the attached and reworked patch ok?
Alasdair, please can we queue this for 2.6.29-rc as urgent bugfix?
Milan
--
mbroz@redhat.com
----
dm-crypt: Fix async completion to not use crypto_async_request directly
In async cryption complete function (kcryptd_async_done), the
crypto_async_request passed in may be different from the one passed to
crypto_ablkcipher_encrypt/decrypt. Only crypto_async_request->data is
guaranteed to be same as the passed in one. Current kcryptd_async_done
uses passed in crypto_async_request directly, which may cause AES-NI
based AES algorithm implementation panic.
This patch fix this bug by using crypto_async_request->data only,
which point to dm_crypt_request, the crypto_async_request passed in
and original data (convert_context) can be gotten from
dm_crypt_request.
Signed-off-by: Huang Ying <ying.huang@intel.com>
Signed-off-by: Milan Broz <mbroz@redhat.com>