CVE-2024-55642: block: Prevent potential deadlocks in zone write plug error recovery
In the Linux kernel, the following vulnerability has been resolved:
block: Prevent potential deadlocks in zone write plug error recovery
Zone write plugging for handling writes to zones of a zoned block device always execute a zone report whenever a write BIO to a zone fails. The intent of this is to ensure that the tracking of a zone write pointer is always correct to ensure that the alignment to a zone write pointer of write BIOs can be checked on submission and that we can always correctly emulate zone append operations using regular write BIOs.
However, this error recovery scheme introduces a potential deadlock if a device queue freeze is initiated while BIOs are still plugged in a zone write plug and one of these write operation fails. In such case, the disk zone write plug error recovery work is scheduled and executes a report zone. This in turn can result in a request allocation in the underlying driver to issue the report zones command to the device. But with the device queue freeze already started, this allocation will block, preventing the report zone execution and the continuation of the processing of the plugged BIOs. As plugged BIOs hold a queue usage reference, the queue freeze itself will never complete, resulting in a deadlock.
Avoid this problem by completely removing from the zone write plugging code the use of report zones operations after a failed write operation, instead relying on the device user to either execute a report zones, reset the zone, finish the zone, or give up writing to the device (which is a fairly common pattern for file systems which degrade to read-only after write failures). This is not an unreasonnable requirement as all well-behaved applications, FSes and device mapper already use report zones to recover from write errors whenever possible by comparing the current position of a zone write pointer with what their assumption about the position is.
The changes to remove the automatic error recovery are as follows: - Completely remove the error recovery work and its associated resources (zone write plug list head, disk error list, and disk zonewplugswork work struct). This also removes the functions diskzonewplugseterror() and diskzonewplugclearerror().
- Change the BLKZONEWPLUGERROR zone write plug flag into BLKZONEWPLUGNEEDWPUPDATE. This new flag is set for a zone write plug whenever a write opration targetting the zone of the zone write plug fails. This flag indicates that the zone write pointer offset is not reliable and that it must be updated when the next report zone, reset zone, finish zone or disk revalidation is executed.
- Modify blkzonewriteplugbioendio() to set the BLKZONEWPLUGNEEDWPUPDATE flag for the target zone of a failed write BIO.
- Modify the function diskzonewplugsetwpoffset() to clear this new flag, thus implementing recovery of a correct write pointer offset with the reset (all) zone and finish zone operations.
- Modify blkdevreportzones() to always use the diskreportzonescb() callback so that diskzonewplugsyncwpoffset() can be called for any zone marked with the BLKZONEWPLUGNEEDWPUPDATE flag. This implements recovery of a correct write pointer offset for zone write plugs marked with BLKZONEWPLUGNEEDWPUPDATE and within the range of the report zones operation executed by the user.
- Modify blkrevalidateseqzone() to call diskzonewplugsyncwpoffset() for all sequential write required zones when a zoned block device is revalidated, thus always resolving any inconsistency between the write pointer offset of zone write plugs and the actual write pointer position of sequential zones.
Other sources
This CVE was automatically created from a reference found in an email or other text. If you are reading this, then this CVE entry is probably erroneous, since this text should be replaced by the official CVE description automatically.
— Launchpad
Affected Software
Remediation
Event History
Frequently Asked Questions
What is the severity of CVE-2024-55642?
The severity of CVE-2024-55642 is categorized as medium due to the potential deadlock issues in zone write error recovery.
How do I fix CVE-2024-55642?
To fix CVE-2024-55642, update the Linux kernel to versions 6.12.6 or newer, or to the 6.13-rc1 or 6.13-rc2 versions.
What versions of the Linux kernel are affected by CVE-2024-55642?
CVE-2024-55642 affects Linux kernel versions from 6.10 up to 6.12.6 and also includes 6.13-rc1 and 6.13-rc2.
What kind of vulnerability is CVE-2024-55642?
CVE-2024-55642 is a vulnerability in the Linux kernel related to block device operations that can lead to potential deadlocks.
Is CVE-2024-55642 exploitable in production environments?
Yes, CVE-2024-55642 could potentially be exploitable in production environments where zoned block devices are used.