Overview
CVE-2026-139022 addresses a vulnerability in the Linux kernel's lib/842 subsystem that governs the 842 compression format. The flaw is reachable when a system uses zram with the 842 algorithm selected and decompresses data from a backing device whose contents can be influenced by an attacker. Under those conditions, the decompressor can write beyond the destination buffer supplied by the caller.
Technical Details
The decompressor entry point sw842_decompress() receives an output buffer whose length represents the caller's capacity. Two operations inside the stream were not validating remaining output before they wrote:
- Indexed copies, which can emit 2, 4, or 8 bytes per operation.
- Short-data templates, which can emit up to 7 bytes per operation.
Neither path verified that there was enough room left in the destination. After an undersized buffer was exceeded, the unsigned output-length counter p->olen could underflow. Because remaining-capacity checks downstream rely on p->olen, those checks subsequently passed even when the stream was already writing past the caller's destination. If the decompressed data ended with a matching CRC, sw842_decompress() returned success despite producing output larger than the supplied capacity.
The published advisory demonstrates the issue by corrupting compressed data on a zram backing device and observing a KASAN vmalloc-out-of-bounds report inside __do_index() and sw842_decompress() when zram reads the corresponding page back.
Affected Systems
The vulnerability is in the lib/842 code path of the Linux kernel and is reachable through zram's compressed writeback path when the 842 compression algorithm is selected. The available context does not specify which kernel versions contain the flaw or which release contains the fix. Operators running kernels that expose zram with 842-format backing storage — particularly on systems where the compressed backing data can be modified by an attacker — should consider themselves potentially exposed pending upstream confirmation of the patched range.
Mitigation
The upstream resolution described in the advisory adds a check of the remaining output length before both the indexed-copy and short-data operations and returns -ENOSPC when the destination cannot accommodate the output, mirroring the behavior used by the other output-producing templates.
Until a fixed kernel is confirmed and deployed, the practical hardening posture is to reduce the attack surface:
- Avoid relying on zram backing storage whose integrity cannot be trusted, especially when 842 is the selected algorithm.
- Prefer storage paths with stronger integrity protections for compressed data that zram reads back.
- Restrict the ability of unprivileged or untrusted actors to modify compressed objects consumed by zram.
Detection Guidance
Operators monitoring kernel telemetry should look for:
- KASAN reports citing
vmalloc-out-of-boundswrites inside__do_index()orsw842_decompress().
- Unexpected decompression failures with
-ENOSPC-style outcomes from the 842 path.
- zram read errors or anomalies in compressed-object integrity around the 842 path.
Indicator note: a matching CRC for decompressed 842 data is not a reliable safety signal in this advisory's scenario, because a valid CRC can coexist with output that exceeds the supplied destination capacity.
Expert Insight
The root cause here is a classic unsigned-counter pattern: a missing pre-write cap check turns an output-cap enforcer into a wraparound liability. Once p->olen underflows, every internal comparison built on it collapses into true, and the decompressor effectively stops policing itself. The flip side is the access predicate: the practical trigger requires an attacker to put crafted compressed data where zram will read it back with 842 selected, which is a fairly narrow precondition in most production deployments. That combination — a real out-of-bounds write primitive on paper, a fairly constrained practical trigger and no observed in-the-wild exploitation — is what places the vulnerability in the low tier rather than higher, while still warranting prompt patching in environments where zram's compressed store is exposed to tampering.
Actionable Recommendations
- Track upstream kernel announcements for the fix commit and confirm the patched release enters your distribution's stable channel.
- Audit any deployment that uses zram with the 842 algorithm and verify the integrity of the backing storage zram reads from.
- Reconsider the 842 algorithm for zram in environments where compressed-data integrity cannot be guaranteed, and evaluate alternative algorithms.
- Add alerting for KASAN
vmalloc-out-of-boundsreports involving__do_index()orsw842_decompress().
- Treat matching CRCs on 842-decompressed data as a necessary but not sufficient integrity indicator on affected kernel versions.
منابع
- git.kernel.org/stable/c/19645460d0e23da2aad0bc78556cd2906d5e5338
- git.kernel.org/stable/c/38ed7182f3491ec1449ff246551e11ad82adba45
- git.kernel.org/stable/c/5f1cc5c7c2ac4f431519f06c9fe539846f0537e7
- git.kernel.org/stable/c/a7c9d73df0489afb3b92a23ea326189237d5df67
- git.kernel.org/stable/c/b9652248b8d7142293edad46799dc80b56d29c04
- git.kernel.org/stable/c/bf2fa75552d5962db8538278d282b454bd88dfff
- git.kernel.org/stable/c/c269cdad3c9c8d7b23bcaccb85d45d8ed4d17928
- git.kernel.org/stable/c/e353f26dd53453919c3796c29f18d51118785208