mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-27 04:47:05 +00:00
crypto: algif_hash - Remove bogus SGL free on zero-length error path
commit24c890dd71
upstream. When a zero-length message is hashed by algif_hash, and an error is triggered, it tries to free an SG list that was never allocated in the first place. Fix this by not freeing the SG list on the zero-length error path. Reported-by: Shigeru Yoshida <syoshida@redhat.com> Reported-by: xingwei lee <xrivendell7@gmail.com> Fixes:b6d972f689
("crypto: af_alg/hash: Fix recvmsg() after sendmsg(MSG_MORE)") Cc: <stable@vger.kernel.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Reported-by: syzbot+3266db0c26d1fbbe3abb@syzkaller.appspotmail.com Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
b5909f197f
commit
775f3c1882
1 changed files with 3 additions and 2 deletions
|
@ -91,13 +91,13 @@ static int hash_sendmsg(struct socket *sock, struct msghdr *msg,
|
|||
if (!(msg->msg_flags & MSG_MORE)) {
|
||||
err = hash_alloc_result(sk, ctx);
|
||||
if (err)
|
||||
goto unlock_free;
|
||||
goto unlock_free_result;
|
||||
ahash_request_set_crypt(&ctx->req, NULL,
|
||||
ctx->result, 0);
|
||||
err = crypto_wait_req(crypto_ahash_final(&ctx->req),
|
||||
&ctx->wait);
|
||||
if (err)
|
||||
goto unlock_free;
|
||||
goto unlock_free_result;
|
||||
}
|
||||
goto done_more;
|
||||
}
|
||||
|
@ -170,6 +170,7 @@ static int hash_sendmsg(struct socket *sock, struct msghdr *msg,
|
|||
|
||||
unlock_free:
|
||||
af_alg_free_sg(&ctx->sgl);
|
||||
unlock_free_result:
|
||||
hash_free_result(sk, ctx);
|
||||
ctx->more = false;
|
||||
goto unlock;
|
||||
|
|
Loading…
Reference in a new issue