Skip to content

Commit

Permalink
crypto: algif_skcipher - Fixed blocking recvmsg
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
Acked-by: Stephan Mueller <[email protected]>
  • Loading branch information
herbertx committed Nov 28, 2014
1 parent 421d82f commit 1e104f9
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions crypto/algif_skcipher.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1e104f9

Please sign in to comment.