Skip to contentSkip to conversation

CVE-2025-39941: zram: fix slot write race condition

DISCUSSION Greg Kroah-Hartman 1 participant 1 message Oct 4, 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:

zram: fix slot write race condition

Parallel concurrent writes to the same zram index result in leaked zsmalloc handles. Schematically we can have something like this:

CPU0 CPU1
zram_slot_lock()
zs_free(handle)
zram_slot_lock()
zram_slot_lock()
zs_free(handle)
zram_slot_lock()

compress compress
handle = zs_malloc() handle = zs_malloc()
zram_slot_lock
zram_set_handle(handle)
zram_slot_lock
zram_slot_lock zram_set_handle(handle) zram_slot_lock

Either CPU0 or CPU1 zsmalloc handle will leak because zs_free() is done too early. In fact, we need to reset zram entry right before we set its new handle, all under the same slot lock scope.

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

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

	Issue introduced in 6.14 with commit 71268035f5d734ad6373d953298bd5779985497a and fixed in 6.16.9 with commit ff750e9f2c4d63854c33967d1646b5e89a9a19a2
	Issue introduced in 6.14 with commit 71268035f5d734ad6373d953298bd5779985497a and fixed in 6.17 with commit ce4be9e4307c5a60701ff6e0cafa74caffdc54ce

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

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:
drivers/block/zram/zram_drv.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/ff750e9f2c4d63854c33967d1646b5e89a9a19a2
	https://git.kernel.org/stable/c/ce4be9e4307c5a60701ff6e0cafa74caffdc54ce