From ca3e435628eb17afbac0e75f8e1d12fb2dcfd16d Mon Sep 17 00:00:00 2001 From: Ivan Pravdin Date: Tue, 15 Jul 2025 14:27:25 +0800 Subject: [PATCH] crypto: algif_hash - fix double free in hash_accept stable inclusion from stable-v6.6.93 commit 134daaba93193df9e988524b5cd2f52d15eb1993 category: bugfix bugzilla: https://gitee.com/src-openeuler/kernel/issues/ICGACQ CVE: CVE-2025-38079 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=134daaba93193df9e988524b5cd2f52d15eb1993 -------------------------------- commit b2df03ed4052e97126267e8c13ad4204ea6ba9b6 upstream. 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: Signed-off-by: Ivan Pravdin Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman Signed-off-by: Gu Bowen --- crypto/algif_hash.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/crypto/algif_hash.c b/crypto/algif_hash.c index e24c829d7a01..5ab7441734b8 100644 --- a/crypto/algif_hash.c +++ b/crypto/algif_hash.c @@ -265,10 +265,6 @@ static int hash_accept(struct socket *sock, struct socket *newsock, int flags, 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); -- Gitee