Hi Herbert,
While testing the algif_aead async patch, I have rerun the async
algif_skcipher tests and I have found some problems.
There are three different issues around algif_skcipher and skcipher.
Two are skcipher conversion related, and one is a bug in the
algif_skcipher, not related to the conversion. It started to
manifest itself after a fix the the qat driver.
v2 changes:
- pass the original skcipher request in ablkcipher.base.data instead of
casting it back from the ablkcipher request.
- rename _req to base_req
- dropped 3/3
---
Tadeusz Struk (2):
crypto: skcipher - return the correct request to the user
crypto: algif_skcipher - fix async callback after skcipher convertion
crypto/algif_skcipher.c | 5 +++--
crypto/skcipher.c | 9 ++++++++-
2 files changed, 11 insertions(+), 3 deletions(-)
--
A user of the skcipher api may have some private context associated with
a request, like for instance the algif_skcipher does, so the api needs to
return the original skcipher_request in the callback instead of the
ablkcipher_request subtype.
Cc: <[email protected]> # 4.4.x-
Signed-off-by: Tadeusz Struk <[email protected]>
---
crypto/skcipher.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/crypto/skcipher.c b/crypto/skcipher.c
index 69230e9..22a9c2a 100644
--- a/crypto/skcipher.c
+++ b/crypto/skcipher.c
@@ -142,6 +142,13 @@ static int skcipher_setkey_ablkcipher(struct crypto_skcipher *tfm,
return err;
}
+static void skcipher_complete(struct crypto_async_request *req_base, int err)
+{
+ struct skcipher_request *req = req_base->data;
+
+ req->base.complete(&req->base, err);
+}
+
static int skcipher_crypt_ablkcipher(struct skcipher_request *req,
int (*crypt)(struct ablkcipher_request *))
{
@@ -151,7 +158,7 @@ static int skcipher_crypt_ablkcipher(struct skcipher_request *req,
ablkcipher_request_set_tfm(subreq, *ctx);
ablkcipher_request_set_callback(subreq, skcipher_request_flags(req),
- req->base.complete, req->base.data);
+ skcipher_complete, req);
ablkcipher_request_set_crypt(subreq, req->src, req->dst, req->cryptlen,
req->iv);
Before the skcipher conversion the async callback used the
crypto_async_request directly as the ablkcipher_request.
It wasn't quite correct, but it worked fine since the
crypto_async_request *base was the first member of the ablkcipher_request
struct. After the skcipher conversion it is not the case anymore and
a proper cast helper needs to be used.
Cc: <[email protected]> # 4.4.x-
Signed-off-by: Tadeusz Struk <[email protected]>
---
crypto/algif_skcipher.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c
index 38c1aa8..927ed7a 100644
--- a/crypto/algif_skcipher.c
+++ b/crypto/algif_skcipher.c
@@ -100,11 +100,12 @@ static void skcipher_free_async_sgls(struct skcipher_async_req *sreq)
kfree(sreq->tsg);
}
-static void skcipher_async_cb(struct crypto_async_request *req, int err)
+static void skcipher_async_cb(struct crypto_async_request *req_base, int err)
{
- struct sock *sk = req->data;
+ struct sock *sk = req_base->data;
struct alg_sock *ask = alg_sk(sk);
struct skcipher_ctx *ctx = ask->private;
+ struct skcipher_request *req = skcipher_request_cast(req_base);
struct skcipher_async_req *sreq = GET_SREQ(req, ctx);
struct kiocb *iocb = sreq->iocb;
On Thu, Jan 28, 2016 at 07:23:54AM -0800, Tadeusz Struk wrote:
> Hi Herbert,
> While testing the algif_aead async patch, I have rerun the async
> algif_skcipher tests and I have found some problems.
> There are three different issues around algif_skcipher and skcipher.
> Two are skcipher conversion related, and one is a bug in the
> algif_skcipher, not related to the conversion. It started to
> manifest itself after a fix the the qat driver.
OK I've decided to fix this differently. The expectation of getting
back the original request is incorrect. There are multiple places
where we will return a request other than the original.
We should probably change the API so that instead of passing the
struct crypto_async_request we just pass in void * instead. That
way nobody could make this mistake.
Anyway, the following patches should fix the algif_skcipher issue.
Cheers,
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt