Update OpenZFS 2.1.14 and 2.2.2 addresses a bug leading to file corruption

Corrective releases for OpenZFS versions 2.1.14 and 2.2.2 have been issued, advancing the implementation of the ZFS file system for Linux and FreeBSD. The updates resolve an issue in the dnode cache consistency check code that caused data corruption in files containing empty areas when copied after modifications.

The issue was initially attempted to be resolved in version 2.2.1, but the fix proved ineffective. The bug remained unnoticed for a long time and began to manifest after changes were made to the 'cp' utility in the coreutils 9.x package. It is assumed that the problem does not manifest in Red Hat Enterprise Linux and its derivative distributions, as RHEL 9 uses the coreutils 8.x package with different logic for the 'cp' utility.

The issue arises when using file copy utilities that can detect and optimize empty areas in files. Corruption may occur in heavily loaded file systems when copying a file if the operation is performed almost immediately after a modification, and part of the data remains only in the dirty cache and has not yet been flushed to disk.

To optimize handling of empty areas in files, OpenZFS, starting from release 0.6.2, supports SEEK_HOLE and SEEK_DATA operations, which allow skipping empty file areas when reading from disk. Detection of empty areas and storage of information about them occurs only after all remaining cached data related to the file has been flushed to disk. To initiate the flush in OpenZFS, there is a check that evaluates the presence of unsaved data in the cache and performs a forced flush of the necessary information to disk for using SEEK_HOLE and SEEK_DATA.

Unfortunately, the check turned out to be incomplete, and under certain circumstances, the reset status was inaccurately determined, leading to the disk containing outdated information about the file's contents. If the request fell within a small time window between two data reset operations from the cache, read operations optimizing the loading of empty areas might have skipped reading some data, considering it empty, while the program working with the file could have made changes to the previously empty areas. As a result, using the 'cp' utility could have led to the creation of a copy containing empty areas where there were none in the original file.

Source: opennet.ru

Buy reliable website hosting with DDoS protection, VPS VDS servers 🔥 Buy reliable website hosting with DDoS protection, VPS VDS servers | ProHoster