Skip to contentSkip to conversation

CVE-2026-43492: lib/crypto: mpi: Fix integer underflow in mpi_read_raw_from_sgl()

DISCUSSION Greg Kroah-Hartman 1 participant 1 message May 19

lore
Share & tools
lore
#0 lore raw

From: Greg Kroah-Hartman <[email protected]>

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

lib/crypto: mpi: Fix integer underflow in mpi_read_raw_from_sgl()

Yiming reports an integer underflow in mpi_read_raw_from_sgl() when subtracting "lzeros" from the unsigned "nbytes".

For this to happen, the scatterlist "sgl" needs to occupy more bytes than the "nbytes" parameter and the first "nbytes + 1" bytes of the scatterlist must be zero. Under these conditions, the while loop iterating over the scatterlist will count more zeroes than "nbytes", subtract the number of zeroes from "nbytes" and cause the underflow.

When commit 2d4d1eea540b ("lib/mpi: Add mpi sgl helpers") originally introduced the bug, it couldn't be triggered because all callers of mpi_read_raw_from_sgl() passed a scatterlist whose length was equal to "nbytes".

However since commit 63ba4d67594a ("KEYS: asymmetric: Use new crypto interface without scatterlists"), the underflow can now actually be triggered. When invoking a KEYCTL_PKEY_ENCRYPT system call with a larger "out_len" than "in_len" and filling the "in" buffer with zeroes, crypto_akcipher_sync_prep() will create an all-zero scatterlist used for both the "src" and "dst" member of struct akcipher_request and thereby fulfil the conditions to trigger the bug:

sys_keyctl()

    keyctl_pkey_e_d_s()
      asymmetric_key_eds_op()
        software_key_eds_op()
          crypto_akcipher_sync_encrypt()
            crypto_akcipher_sync_prep()
              crypto_akcipher_encrypt()
                rsa_enc()
                  mpi_read_raw_from_sgl()

To the user this will be visible as a DoS as the kernel spins forever, causing soft lockup splats as a side effect.

Fix it.

The Linux kernel CVE team has assigned CVE-2026-43492 to this issue.

Affected and fixed versions
===========================

	Issue introduced in 4.4 with commit 2d4d1eea540b27c72488fd1914674c42473d53df and fixed in 6.6.140 with commit 2aa77a18dc7f2670497fe3ee5acbeda0b57659e5
	Issue introduced in 4.4 with commit 2d4d1eea540b27c72488fd1914674c42473d53df and fixed in 6.12.88 with commit 26d3a97ad46c7a9226ec04d4bf35bd4998a97d16
	Issue introduced in 4.4 with commit 2d4d1eea540b27c72488fd1914674c42473d53df and fixed in 6.18.30 with commit 8637dfb4c1d8a7026ef681f2477c6de8b71c4003
	Issue introduced in 4.4 with commit 2d4d1eea540b27c72488fd1914674c42473d53df and fixed in 7.0.7 with commit 30e513e755bb381afce6fb57cdc8694136193f22
	Issue introduced in 4.4 with commit 2d4d1eea540b27c72488fd1914674c42473d53df and fixed in 7.1-rc1 with commit 8c2f1288250a90a4b5cabed5d888d7e3aeed4035

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-2026-43492

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:
lib/crypto/mpi/mpicoder.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/2aa77a18dc7f2670497fe3ee5acbeda0b57659e5
	https://git.kernel.org/stable/c/26d3a97ad46c7a9226ec04d4bf35bd4998a97d16
	https://git.kernel.org/stable/c/8637dfb4c1d8a7026ef681f2477c6de8b71c4003
	https://git.kernel.org/stable/c/30e513e755bb381afce6fb57cdc8694136193f22
	https://git.kernel.org/stable/c/8c2f1288250a90a4b5cabed5d888d7e3aeed4035