Re: [PATCH] zram: validate decompressed page size

From: Sergey Senozhatsky

Date: Thu Nov 26 2026 - 21:11:09 EST


Hi Artem,

On (26/11/26 19:34), Artem Novak wrote:
> Hey Sergey,
>
> On Thu, Nov 26, 2026 at 7:19 PM Sergey Senozhatsky
> <senozhatsky@xxxxxxxxxxxx> wrote:
> > Yeah, I don't think we should do this. We only ever compress PAGE_SIZE
> > buffers, if some backend decompresses it to a something that is not
> > PAGE_SIZE and doesn't signal an error via "ret" then it's a bug in the
> > backend and zram should not cover it up.
>
> I see.
>
> I thought it might be worth having a defensive check here,
> since allowing an incorrectly sized result to propagate seems a bit sloppy.
>
> Do you consider this useful, or should I rely completely on the
> backend contract?

I would probably prefer to do nothing about it, IOW rely on the
backend contract. Most of those compression libraries are used
in other places in the kernel (f2fs, squashfs, etc. etc.), zram
is not the only one to rely on them.