CVE-2025-40063: crypto: comp - Use same definition of context alloc and free ops
From: Greg Kroah-Hartman <[email protected]>
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
crypto: comp - Use same definition of context alloc and free ops
In commit 42d9f6c77479 ("crypto: acomp - Move scomp stream allocation code into acomp"), the crypto_acomp_streams struct was made to rely on having the alloc_ctx and free_ctx operations defined in the same order as the scomp_alg struct. But in that same commit, the alloc_ctx and free_ctx members of scomp_alg may be randomized by structure layout randomization, since they are contained in a pure ops structure (containing only function pointers). If the pointers within scomp_alg are randomized, but those in crypto_acomp_streams are not, then the order may no longer match. This fixes the problem by removing the union from scomp_alg so that both crypto_acomp_streams and scomp_alg will share the same definition of alloc_ctx and free_ctx, ensuring they will always have the same layout.
The Linux kernel CVE team has assigned CVE-2025-40063 to this issue.
Affected and fixed versions
===========================
Issue introduced in 6.16 with commit 42d9f6c774790d290c175e8775ce9f1366438098 and fixed in 6.17.3 with commit 779d3b6f2d32c5f1da6163e959abe1e1ffe2945b Issue introduced in 6.16 with commit 42d9f6c774790d290c175e8775ce9f1366438098 and fixed in 6.18-rc1 with commit f75f66683ded09f7135aef2e763c245a07c8271a
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-40063
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:
crypto/842.c crypto/lz4.c crypto/lz4hc.c crypto/lzo-rle.c crypto/lzo.c drivers/crypto/nx/nx-common-powernv.c drivers/crypto/nx/nx-common-pseries.c include/crypto/internal/scompress.h
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/779d3b6f2d32c5f1da6163e959abe1e1ffe2945b https://git.kernel.org/stable/c/f75f66683ded09f7135aef2e763c245a07c8271a