Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 28B2B21E0AF for ; Thu, 4 Dec 2025 16:08:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764864483; cv=none; b=WeFyTk0CatZDXmg3+BnpOInykHmKB6YkcJc1W9ZnjXE6Hn2QWygrifeeINQd2BTvBw7MimYqxxgLCMgCLLk8YzdqwUWGv41pToNcVoJ4tpGPIh4jU5oom8hAho/sURfGIN4KLq/cQ/Ztvq6STR2OJ1KNs+/N3AKoH6rLGTpu3+s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764864483; c=relaxed/simple; bh=ug0/WgnOQmuS37nHrWEx/TgF3jzywo7Q1hhI9OaAy6k=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=kBEUQ/PftsKtzg/yLieOsY3Iia/gdrTVtwRibbMiahwNW1Y7iHfwihWybhRnd6XF+VIy418LDfiWuXjRJr6C5G5jYKpf+Bu7QA1hQ45nkpFG4UxoYSyt4M6Hx2S6EUSuMlFN60dXDSlQAXqbFHt4jevp31ZUMwxpgyca0MiyiBE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=xEL7YHBB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="xEL7YHBB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3DBAEC4CEFB; Thu, 4 Dec 2025 16:08:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1764864481; bh=ug0/WgnOQmuS37nHrWEx/TgF3jzywo7Q1hhI9OaAy6k=; h=From:To:Cc:Subject:Date:Reply-To:From; b=xEL7YHBBh5IpCCYA9QffwaumaOA/OiNmKoX/KkMHHRji3RkcEstyReE3n+1Dl5l4O YjTDcHME4cIZRBvdE2Dz/CggetKjbMRRWaQzlyFS5qUPKL8EfUNTkYQLHzLZ+VJJxZ oEUG6NQQEGphVZTea7/2aLvKrUMJj8mcB0TFpd0U= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2025-40256: xfrm: also call xfrm_state_delete_tunnel at destroy time for states that were never added Date: Thu, 4 Dec 2025 16:57:37 +0100 Message-ID: <2025120432-CVE-2025-40256-9de9@gregkh> X-Mailer: git-send-email 2.52.0 Reply-To: , Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3116; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=N/N1sdi/9VNeovu1aBzrw4UrcoQC6x171Qt7HIXSIXc=; b=owGbwMvMwCRo6H6F97bub03G02pJDJmG63PkZaJro1dE+V1f01wWKfEq5nLXnZbuY0lK+mydn c4lSy92xLIwCDIxyIopsnzZxnN0f8UhRS9D29Mwc1iZQIYwcHEKwEQaPBnme+ee+7MhMGCm6Ulp gdfrSnoXbFurwDDfQzsmO8exzGbpn1c6Jtd3LbF/da8XAA== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit From: Greg Kroah-Hartman Description =========== In the Linux kernel, the following vulnerability has been resolved: xfrm: also call xfrm_state_delete_tunnel at destroy time for states that were never added In commit b441cf3f8c4b ("xfrm: delete x->tunnel as we delete x"), I missed the case where state creation fails between full initialization (->init_state has been called) and being inserted on the lists. In this situation, ->init_state has been called, so for IPcomp tunnels, the fallback tunnel has been created and added onto the lists, but the user state never gets added, because we fail before that. The user state doesn't go through __xfrm_state_delete, so we don't call xfrm_state_delete_tunnel for those states, and we end up leaking the FB tunnel. There are several codepaths affected by this: the add/update paths, in both net/key and xfrm, and the migrate code (xfrm_migrate, xfrm_state_migrate). A "proper" rollback of the init_state work would probably be doable in the add/update code, but for migrate it gets more complicated as multiple states may be involved. At some point, the new (not-inserted) state will be destroyed, so call xfrm_state_delete_tunnel during xfrm_state_gc_destroy. Most states will have their fallback tunnel cleaned up during __xfrm_state_delete, which solves the issue that b441cf3f8c4b (and other patches before it) aimed at. All states (including FB tunnels) will be removed from the lists once xfrm_state_fini has called flush_work(&xfrm_state_gc_work). The Linux kernel CVE team has assigned CVE-2025-40256 to this issue. Affected and fixed versions =========================== Issue introduced in 6.16 with commit b441cf3f8c4b8576639d20c8eb4aa32917602ecd and fixed in 6.17.10 with commit d6fe5c740c573af10943b8353992e1325cdb2715 Issue introduced in 6.16 with commit b441cf3f8c4b8576639d20c8eb4aa32917602ecd and fixed in 6.18 with commit 10deb69864840ccf96b00ac2ab3a2055c0c04721 Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community. Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at https://cve.org/CVERecord/?id=CVE-2025-40256 will be updated if fixes are backported, please check that for the most up to date information about this issue. Affected files ============== The file(s) affected by this issue are: net/xfrm/xfrm_state.c Mitigation ========== The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits: https://git.kernel.org/stable/c/d6fe5c740c573af10943b8353992e1325cdb2715 https://git.kernel.org/stable/c/10deb69864840ccf96b00ac2ab3a2055c0c04721