linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephan Mueller <smueller@chronox.de>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Linux Crypto Mailing List <linux-crypto@vger.kernel.org>
Subject: Re: crypto: algif_skcipher - Fixed blocking recvmsg
Date: Thu, 27 Nov 2014 15:45:29 +0100	[thread overview]
Message-ID: <7895068.9zYFrJNGYN@tauon> (raw)
In-Reply-To: <20141127143811.GA25283@gondor.apana.org.au>

Am Donnerstag, 27. November 2014, 22:38:12 schrieb Herbert Xu:

Hi Herbert,

>As most (all?) users of algif_skcipher are single-threaded and
>therefore always write before reading from an algif_skcipher
>socket, they never block and exercise that code-path.
>
>It turns out that code path doesn't even work because we never
>reload ctx->used after waking up so we never even see the new
>data and immediately return an error (and a loud WARN_ON).
>
>This patch fixes this by always reloading ctx->used.
>
>Reported-by: Stephan Mueller <smueller@chronox.de>
>Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Acked-by: Stephan Mueller <smueller@chronox.de>
>
>diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c
>index 3438996..f80e652 100644
>--- a/crypto/algif_skcipher.c
>+++ b/crypto/algif_skcipher.c
>@@ -448,14 +448,13 @@ static int skcipher_recvmsg(struct kiocb *unused,
>struct socket *sock, while (!sg->length)
> 				sg++;
>
>-			used = ctx->used;
>-			if (!used) {
>+			if (!ctx->used) {
> 				err = skcipher_wait_for_data(sk, flags);
> 				if (err)
> 					goto unlock;
> 			}
>
>-			used = min_t(unsigned long, used, seglen);
>+			used = min_t(unsigned long, ctx->used, seglen);
>
> 			used = af_alg_make_sg(&ctx->rsgl, from, used, 
1);
> 			err = used;
>
>Thanks,


Ciao
Stephan

      reply	other threads:[~2014-11-27 14:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-27 14:38 crypto: algif_skcipher - Fixed blocking recvmsg Herbert Xu
2014-11-27 14:45 ` Stephan Mueller [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7895068.9zYFrJNGYN@tauon \
    --to=smueller@chronox.de \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).