* [PATCH v2 1/2] crypto: skcipher - return the correct request to the user
2016-01-28 15:23 [PATCH v2 0/2] crypto: afalg_skcipher - fixes after skcipher conversion Tadeusz Struk
@ 2016-01-28 15:24 ` Tadeusz Struk
2016-01-28 15:24 ` [PATCH v2 2/2] crypto: algif_skcipher - fix async callback after skcipher convertion Tadeusz Struk
1 sibling, 0 replies; 3+ messages in thread
From: Tadeusz Struk @ 2016-01-28 15:24 UTC (permalink / raw)
To: herbert; +Cc: linux-crypto, stable, tadeusz.struk
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: <stable@vger.kernel.org> # 4.4.x-
Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
---
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);
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH v2 2/2] crypto: algif_skcipher - fix async callback after skcipher convertion
2016-01-28 15:23 [PATCH v2 0/2] crypto: afalg_skcipher - fixes after skcipher conversion Tadeusz Struk
2016-01-28 15:24 ` [PATCH v2 1/2] crypto: skcipher - return the correct request to the user Tadeusz Struk
@ 2016-01-28 15:24 ` Tadeusz Struk
1 sibling, 0 replies; 3+ messages in thread
From: Tadeusz Struk @ 2016-01-28 15:24 UTC (permalink / raw)
To: herbert; +Cc: linux-crypto, stable, tadeusz.struk
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: <stable@vger.kernel.org> # 4.4.x-
Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
---
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;
^ permalink raw reply related [flat|nested] 3+ messages in thread