]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
crypto: algif_hash - fix double free in hash_accept
authorIvan Pravdin <ipravdin.official@gmail.com>
Sun, 18 May 2025 22:41:02 +0000 (18:41 -0400)
committerHerbert Xu <herbert@gondor.apana.org.au>
Mon, 19 May 2025 05:44:16 +0000 (13:44 +0800)
If accept(2) is called on socket type algif_hash with
MSG_MORE flag set and crypto_ahash_import fails,
sk2 is freed. However, it is also freed in af_alg_release,
leading to slab-use-after-free error.

Fixes: fe869cdb89c9 ("crypto: algif_hash - User-space interface for hash operations")
Cc: <stable@vger.kernel.org>
Signed-off-by: Ivan Pravdin <ipravdin.official@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/algif_hash.c

index 5498a87249d3e79f9f431458257fcc32a76275ac..e3f1a4852737b02294be94d9a9300faee1b7c3b4 100644 (file)
@@ -265,10 +265,6 @@ static int hash_accept(struct socket *sock, struct socket *newsock,
                goto out_free_state;
 
        err = crypto_ahash_import(&ctx2->req, state);
-       if (err) {
-               sock_orphan(sk2);
-               sock_put(sk2);
-       }
 
 out_free_state:
        kfree_sensitive(state);