Re: [RFC PATCH] mm/zswap: store compression failed page as-is

From: Nhat Pham
Date: Wed Jul 30 2025 - 20:23:10 EST


On Wed, Jul 30, 2025 at 5:21 PM Nhat Pham <nphamcs@xxxxxxxxx> wrote:
>
> On Wed, Jul 30, 2025 at 4:41 PM SeongJae Park <sj@xxxxxxxxxx> wrote:
>
> This might not be safe.
>
> It's conceivable that in zswap_compress(), some compression algorithm
> "successfully" compresses a page to the same size (comp_ret == 0). We
> hand that to zsmalloc, which happily stores the page.
>
> When we "decompress" the page again, we will attempt to
> memcpy_to_folio from a bogus address (the handle from zsmalloc).
>
> So, in zswap_compress, you have to treat both comp_ret == 0 and dlen
> == PAGE_SIZE as "compression failure".

Meant to say comp_ret != 0 here... sorry for the confusion...