Re: [PATCH] zram: validate decompressed page size

From: Artem Novak

Date: Thu Nov 26 2026 - 20:34:41 EST


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?

>
> On (26/11/26 18:44), Artem Novak wrote:
> [..]
> > @@ -185,6 +185,8 @@ int zcomp_decompress(struct zcomp *comp, struct zcomp_strm *zstrm,
> > ret = comp->ops->decompress(comp->params, &zstrm->ctx, &req);
> > if (src)
> > kunmap_local(src);
> > + if (!ret && req.dst_len != PAGE_SIZE)
> > + ret = -EINVAL;
> > return ret;
> > }
>