2010-04-26 01:17:34

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] net/ipsec: don't treat EINPROGRESS as a regular error

On Sun, Apr 25, 2010 at 05:29:28PM +0200, Sebastian Andrzej Siewior wrote:
> * Herbert Xu | 2010-04-25 09:18:21 [+0800]:
>
> >This should only be possible when we use the MAY_BACKLOG flag,
> >as otherwise EINPROGRESS should never be used on the completion
> >function unless it's a real error.
> Urgh, right. I think I lost it.
>
> >Which algorithm is generating EINPROGRESS in this case?
> The call stack looks like the following:
>
> crypto_authenc_givencrypt_done()
> \crypto_authenc_ahash
> \crypto_ahash_digest()
> \mv_hash_digest()
> \crypto_enqueue_request() <= -EINPROGRESS

OK that was my fault. Steffen had all the requisite EINPROGRESS
checks in place but I told him to get rid of them.

This patch should fix it.

commit 180ce7e81030e1ef763d58f97f9ab840ff57d848
Author: Herbert Xu <[email protected]>
Date: Mon Apr 26 09:14:05 2010 +0800

crypto: authenc - Add EINPROGRESS check

When Steffen originally wrote the authenc async hash patch, he
correctly had EINPROGRESS checks in place so that we did not invoke
the original completion handler with it.

Unfortuantely I told him to remove it before the patch was applied.

As only MAY_BACKLOG request completion handlers are required to
handle EINPROGRESS completions, those checks are really needed.

This patch restores them.

Reported-by: Sebastian Andrzej Siewior <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>

diff --git a/crypto/authenc.c b/crypto/authenc.c
index 2bb7348..05eb32e 100644
--- a/crypto/authenc.c
+++ b/crypto/authenc.c
@@ -46,6 +46,12 @@ struct authenc_request_ctx {
char tail[];
};

+static void authenc_request_complete(struct aead_request *req, int err)
+{
+ if (err != -EINPROGRESS)
+ aead_request_complete(req, err);
+}
+
static int crypto_authenc_setkey(struct crypto_aead *authenc, const u8 *key,
unsigned int keylen)
{
@@ -142,7 +148,7 @@ static void authenc_geniv_ahash_update_done(struct crypto_async_request *areq,
crypto_aead_authsize(authenc), 1);

out:
- aead_request_complete(req, err);
+ authenc_request_complete(req, err);
}

static void authenc_geniv_ahash_done(struct crypto_async_request *areq, int err)
@@ -208,7 +214,7 @@ static void authenc_verify_ahash_update_done(struct crypto_async_request *areq,
err = crypto_ablkcipher_decrypt(abreq);

out:
- aead_request_complete(req, err);
+ authenc_request_complete(req, err);
}

static void authenc_verify_ahash_done(struct crypto_async_request *areq,
@@ -245,7 +251,7 @@ static void authenc_verify_ahash_done(struct crypto_async_request *areq,
err = crypto_ablkcipher_decrypt(abreq);

out:
- aead_request_complete(req, err);
+ authenc_request_complete(req, err);
}

static u8 *crypto_authenc_ahash_fb(struct aead_request *req, unsigned int flags)
@@ -379,7 +385,7 @@ static void crypto_authenc_encrypt_done(struct crypto_async_request *req,
err = crypto_authenc_genicv(areq, iv, 0);
}

- aead_request_complete(areq, err);
+ authenc_request_complete(areq, err);
}

static int crypto_authenc_encrypt(struct aead_request *req)
@@ -420,7 +426,7 @@ static void crypto_authenc_givencrypt_done(struct crypto_async_request *req,
err = crypto_authenc_genicv(areq, greq->giv, 0);
}

- aead_request_complete(areq, err);
+ authenc_request_complete(areq, err);
}

static int crypto_authenc_givencrypt(struct aead_givcrypt_request *req)

Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


Subject: Re: [PATCH] net/ipsec: don't treat EINPROGRESS as a regular error

* Herbert Xu | 2010-04-26 09:17:11 [+0800]:

>OK that was my fault. Steffen had all the requisite EINPROGRESS
>checks in place but I told him to get rid of them.
>
>This patch should fix it.
Excellent job Herbert, it does solve the problem.

Sebastian

2010-04-27 01:35:28

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] net/ipsec: don't treat EINPROGRESS as a regular error

On Mon, Apr 26, 2010 at 08:11:42PM +0200, Sebastian Andrzej Siewior wrote:
>
> Excellent job Herbert, it does solve the problem.

Thanks for testing.
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

2010-05-21 19:09:15

by Martin Michlmayr

[permalink] [raw]
Subject: Re: [PATCH] net/ipsec: don't treat EINPROGRESS as a regular error

* Sebastian Andrzej Siewior <[email protected]> [2010-04-26 20:11]:
> >OK that was my fault. Steffen had all the requisite EINPROGRESS
> >checks in place but I told him to get rid of them.
> >
> >This patch should fix it.
> Excellent job Herbert, it does solve the problem.

Herbert, this bug was originally reported with 2.6.32 so can you
please ensure that the fix will land in -stable.

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=180ce7e81030e1ef763d58f97f9ab840ff57d848

Thanks.
--
Martin Michlmayr
http://www.cyrius.com/

2010-05-21 23:42:07

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] net/ipsec: don't treat EINPROGRESS as a regular error

On Fri, May 21, 2010 at 07:59:05PM +0100, Martin Michlmayr wrote:
> * Sebastian Andrzej Siewior <[email protected]> [2010-04-26 20:11]:
> > >OK that was my fault. Steffen had all the requisite EINPROGRESS
> > >checks in place but I told him to get rid of them.
> > >
> > >This patch should fix it.
> > Excellent job Herbert, it does solve the problem.
>
> Herbert, this bug was originally reported with 2.6.32 so can you
> please ensure that the fix will land in -stable.
>
> http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=180ce7e81030e1ef763d58f97f9ab840ff57d848

Thanks, I will forward it to stable.
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt