Skip to content

Commit fe09786

Browse files
ruiwang1herbertx
authored andcommitted
crypto: algif_hash - wait for crypto_ahash_init() to complete
hash_sendmsg/sendpage() need to wait for the completion of crypto_ahash_init() otherwise it can cause panic. Cc: [email protected] Signed-off-by: Rui Wang <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 00420a6 commit fe09786

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

crypto/algif_hash.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ static int hash_sendmsg(struct socket *sock, struct msghdr *msg,
5454

5555
lock_sock(sk);
5656
if (!ctx->more) {
57-
err = crypto_ahash_init(&ctx->req);
57+
err = af_alg_wait_for_completion(crypto_ahash_init(&ctx->req),
58+
&ctx->completion);
5859
if (err)
5960
goto unlock;
6061
}
@@ -125,6 +126,7 @@ static ssize_t hash_sendpage(struct socket *sock, struct page *page,
125126
} else {
126127
if (!ctx->more) {
127128
err = crypto_ahash_init(&ctx->req);
129+
err = af_alg_wait_for_completion(err, &ctx->completion);
128130
if (err)
129131
goto unlock;
130132
}

0 commit comments

Comments
 (0)