Skip to contentSkip to conversation

CVE-2025-37984: crypto: ecdsa - Harden against integer overflows in DIV_ROUND_UP()

DISCUSSION Greg Kroah-Hartman 1 participant 1 message May 20, 2025

lore
Share & tools
lore
#0 lore raw

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

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

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

crypto: ecdsa - Harden against integer overflows in DIV_ROUND_UP()

Herbert notes that DIV_ROUND_UP() may overflow unnecessarily if an ecdsa implementation's ->key_size() callback returns an unusually large value. Herbert instead suggests (for a division by 8):

X / 8 + !!(X & 7)

Based on this formula, introduce a generic DIV_ROUND_UP_POW2() macro and use it in lieu of DIV_ROUND_UP() for ->key_size() return values.

Additionally, use the macro in ecc_digits_from_bytes(), whose "nbytes" parameter is a ->key_size() return value in some instances, or a user-specified ASN.1 length in the case of ecdsa_get_signature_rs().

The Linux kernel CVE team has assigned CVE-2025-37984 to this issue.

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

	Fixed in 6.14.5 with commit 921b8167f10708e38080f84e195cdc68a7a561f1
	Fixed in 6.15-rc1 with commit b16510a530d1e6ab9683f04f8fb34f2e0f538275

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-37984

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/ecc.c
	crypto/ecdsa-p1363.c
	crypto/ecdsa-x962.c
	include/linux/math.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/921b8167f10708e38080f84e195cdc68a7a561f1
	https://git.kernel.org/stable/c/b16510a530d1e6ab9683f04f8fb34f2e0f538275