The EROFS read-only file-system popular for embedded systems, containers, and other use-cases has resorted to temporarily disabling its LZ4 rolling decompression support due to data corruption concerns. Ahead of the Linux 7.3-rc3 kernel release due out on Sunday, EROFS has mid-cycle deemed it necessary to disable the LZ4 rolling data decompression capability it supported. Today's EROFS merge noted: "The most impactful fix here is to disable LZ4 rolling decompression for now. AWS folks recently found their systems could get corrupted data with some rare, specific LZ4 datasets, and after a deeper analysis, I found the root cause is that there could be uncontrolled backward memory copies in the current LZ4 implementation and it breaks the assumption of the rolling decompression optimization, since the kernel LZ4 codebase is out of our control and it needs more time to plan how to do next, so disable LZ4 rolling decompression for now to ensure data correctness for real production on these rare cases first." The patch to disable it further explains the issue and impact: "LZ4 rolling decompression was introduced to reduce the memory footprint of temporary pages: For many cases, it is needed for users to read small data within a compressed extent (pcluster), either due to random small read, or since uptodate folios (typically order-0) cannot be reused for decompression again since decompression algorithm refills already-uptodate folios. Rolling decompression works because LZ4 is LZ77-based and only refers to the most recent 64 KiB of decompressed data, so in theory only a bounded rolling window of temporary pages is needed when decompressing. It can save a lot of temporary memory, e.g. 601,960-byte data can be compressed into a 256k LZ4 compressed extent, which means it needs 146 extra pages per request in the worst case if rolling decompression is disabled. However, the upstream LZ4 implementation is not under EROFS' control: For example, the literal copy memmove() may still **copy long literals backward** on x86 based on the address comparison even when the source and destination ranges do not overlap (IOWs, inline decompression doesn't need to be considered here). That breaks the rolling assumption and makes the optimization broken. Disable it for now to make sure the data correctness first since EROFS is used everywhere now: The rolling window approach can be revived once we either ensure that the official LZ4 code always copies forward for non-overlapping ranges or maintain our own LZ4 implementation in EROFS. The main impact is a higher runtime memory footprint; However, recent commit 0f6273ab4637 ("erofs: add a reserved buffer pool for lz4 decompression") helps mitigate this when enabled but it's still not perfect." So for Linux 7.3 at least, the EROFS LZ4 rolling decompression functionality is now disabled.
EROFS Disables LZ4 Rolling Decompression Due To Data Corruption Possibility
Full Article
Original Source
Read the full article at Phoronix →KhanList aggregates and links to publicly available news content. We do not host full articles from third-party sources. Always verify important information with original sources.