mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: haoqin huang <haoqinhuang7@gmail.com>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>,
	minchan@kernel.org,  axboe@kernel.dk, terrelln@fb.com,
	dsterba@suse.com, akpm@linux-foundation.org,
	 linux-kernel@vger.kernel.org, linux-block@vger.kernel.org,
	rongwei.wrw@gmail.com,  Haoqin Huang <haoqinhuang@tencent.com>,
	Rongwei Wang <zigiwang@tencent.com>
Subject: Re: [PATCH 2/3] zram: add per-backend capability flags and validate parameters early
Date: Tue, 28 Jul 2026 10:19:44 +0900	[thread overview]
Message-ID: <amgB3pPhKEmFkMEQ@google.com> (raw)
In-Reply-To: <CAEjiKSknejc9biofmnJu_3xamZj8kuvbxiPuKp6phQJdGwQPCQ@mail.gmail.com>

On (26/07/28 00:50), haoqin huang wrote:
> On Fri, Jul 24, 2026 at 1:28 PM Sergey Senozhatsky
> <senozhatsky@chromium.org> wrote:
> >
> > On (26/06/27 15:02), Haoqin Huang wrote:
> > > Writing dict or level parameters for algorithms that don't support
> > > them was silently accepted but had no effect.  Out-of-range levels
> > > were silently clamped by the underlying library.  Dict read failures
> > > always lost the real error from kernel_read_file_from_path().
> > >
> > > Add caps, level_min and level_max to zcomp_ops and validate
> > > user-supplied parameters in algorithm_params_store() before storing,
> > > giving immediate error feedback. Also fix comp_params_store() to
> > > read the new dict into a temporary buffer before resetting old
> > > parameters, making the update atomic.
> >
> > I probably would prefer not to add this.  Again, zram setup is almost
> > always automated, you figure out what you need to put into your init
> > script once and you never touch it again.
> >
> 
> That's a fair point. The sysfs validation is admittedly defensive.
> 
> My thinking was just that without any feedback, a misconfiguration can
> be hard to notice. For instance:
> 
>  algo=lzo dict=/data/dict    -> setup_params() silently discards it
>  algo=deflate dict=/data/dict -> same, silently ignored
>  algo=zstd level=999         -> silently clamped to 22 by the library
> 
> All of these succeed without a peep -- not a crash, but also no
> indication that anything was wrong.

We were thinking about moving from zcomp to crypto API acomp.  So I'm
not sure if we want to invest a lot of time into zcomp.  If you want
to have it then I'd ask to split caps and kernel_read_file_from_path()
zero i_size check into separate patches.  We also probably want some
pr_err() on failed validation, because just returning -EINVAL doesn't
explain the error and doesn't help the (supposedly) clueless user
who attempts to configure zram by throwing random numbers at it.

> > The 0 i_size for CD-dict is something that simply should not happen.
> > If you insist on handling that then we can replace "sz < 0" with "sz <= 0",
> > but that 0 len dictionary case is something purely theoretical.
> 
> That's fine, I'll use sz <= 0 in v2.
> 
> Anyway, let me split the original patch so the non-controversial part
> stands on its own:
> 
>   [2/3] zram: make dict update in comp_params_store() atomic
> 
>     Move comp_params_reset() after kernel_read_file_from_path(), so an
>     I/O error doesn't leave the old dict freed with nothing to replace
>     it.  Also preserve the actual error code.
> 
>   [3/3] zram: add per-backend caps and validate parameters early
> 
>     Optional -- happy to drop if you still feel it's unnecessary.

Sounds good.

  reply	other threads:[~2026-07-28  1:19 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-27  7:02 [PATCH 1/3] zram: fix zstd dict use-after-free on per-CPU error path Haoqin Huang
2026-06-27  7:02 ` [PATCH 2/3] zram: add per-backend capability flags and validate parameters early Haoqin Huang
2026-07-24  5:27   ` Sergey Senozhatsky
2026-07-27 16:50     ` haoqin huang
2026-07-28  1:19       ` Sergey Senozhatsky [this message]
2026-07-28  9:07         ` haoqin huang
2026-07-28  1:27   ` Sergey Senozhatsky
2026-07-28  9:09     ` haoqin huang
2026-06-27  7:02 ` [PATCH 3/3] zram: reset per-priority params when changing algorithm before init Haoqin Huang
2026-07-24  5:19   ` Sergey Senozhatsky
2026-07-07  7:19 ` [PATCH 1/3] zram: fix zstd dict use-after-free on per-CPU error path Sergey Senozhatsky
2026-07-24  5:17 ` Sergey Senozhatsky
2026-07-27 16:06   ` haoqin huang
2026-07-28  1:21     ` Sergey Senozhatsky
2026-07-28  9:29 ` [PATCH v2 1/5] zram: fix early release of global cdict/ddict in " Haoqin Huang
2026-07-28  9:29   ` [PATCH v2 2/5] zram: make dict update in comp_params_store() atomic Haoqin Huang
2026-07-29  2:30     ` Sergey Senozhatsky
2026-07-29  4:06       ` haoqin huang
2026-07-29  4:16         ` Sergey Senozhatsky
2026-07-29  4:25           ` haoqin huang
2026-07-28  9:29   ` [PATCH v2 3/5] zstd: move ZSTD_MAX_CLEVEL to zstd_lib.h Haoqin Huang
2026-07-29  3:03     ` Sergey Senozhatsky
2026-07-29  4:16       ` haoqin huang
2026-07-29  4:22         ` Sergey Senozhatsky
2026-07-29  4:32           ` haoqin huang
2026-07-29  4:49             ` Sergey Senozhatsky
2026-07-30  2:48               ` haoqin huang
2026-07-28  9:29   ` [PATCH v2 4/5] zram: add per-backend caps and validate parameters early Haoqin Huang
2026-07-29  2:26     ` Sergey Senozhatsky
2026-07-29  3:53       ` haoqin huang
2026-07-28  9:29   ` [PATCH v2 5/5] zram: reset per-priority params when changing algorithm before init Haoqin Huang
2026-07-29  0:34   ` [PATCH v2 1/5] zram: fix early release of global cdict/ddict in per-CPU error path Andrew Morton
2026-07-29  2:49     ` Sergey Senozhatsky
2026-07-29  3:33     ` haoqin huang
2026-07-29  2:20   ` Sergey Senozhatsky
2026-07-29  3:40     ` haoqin huang
2026-07-29  2:40   ` Sergey Senozhatsky
2026-07-30  2:52   ` [PATCH v3 0/5] zram: fix zstd per-CPU error path and add parameter validation Haoqin Huang
2026-07-30  2:52     ` [PATCH v3 1/5] zram: do not release zstd params in per-CPU error path Haoqin Huang
2026-07-30  2:52     ` [PATCH v3 2/5] zram: reject zero-size dictionary Haoqin Huang
2026-07-30  2:52     ` [PATCH v3 3/5] zram: add level validation in zstd setup_params Haoqin Huang
2026-07-30  3:10       ` Sergey Senozhatsky
2026-07-30  5:55         ` haoqin huang
2026-07-30  2:52     ` [PATCH v3 4/5] zram: add per-backend caps and validate parameters early Haoqin Huang
2026-07-30  3:14       ` Sergey Senozhatsky
2026-07-30  5:57         ` haoqin huang
2026-07-30  2:52     ` [PATCH v3 5/5] zram: reset per-priority params when changing algorithm before init Haoqin Huang
2026-07-30  6:01     ` [PATCH v4 0/4] zram: fix zstd per-CPU error path and add parameter validation Haoqin Huang
2026-07-30  6:01       ` [PATCH v4 1/4] zram: do not release zstd params in per-CPU error path Haoqin Huang
2026-07-30  6:01       ` [PATCH v4 2/4] zram: reject zero-size dictionary Haoqin Huang
2026-07-30  7:00         ` Sergey Senozhatsky
2026-07-30  6:01       ` [PATCH v4 3/4] zram: validate parameters in each backend's setup_params Haoqin Huang
2026-07-30  7:24         ` Sergey Senozhatsky
2026-08-03 12:20           ` haoqin huang
2026-08-04  4:42             ` Sergey Senozhatsky
2026-08-05  1:26               ` Jaegeuk Kim
2026-07-30  7:35         ` Sergey Senozhatsky
2026-07-30  6:01       ` [PATCH v4 4/4] zram: reset per-priority params when changing algorithm before init Haoqin Huang
2026-07-30  7:28         ` Sergey Senozhatsky
2026-08-03 14:12       ` [PATCH v5 0/4] zram: fix zstd error paths and add parameter validation Haoqin Huang
2026-08-03 14:12         ` [PATCH v5 1/4] zram: do not release zstd global params from error paths Haoqin Huang
2026-08-03 14:12         ` [PATCH v5 2/4] zram: reject zero-size dictionary Haoqin Huang
2026-08-04  5:32           ` Sergey Senozhatsky
2026-08-04  7:15             ` haoqin huang
2026-08-03 14:12         ` [PATCH v5 3/4] zram: validate parameters in each backend's setup_params Haoqin Huang
2026-08-04  5:36           ` Sergey Senozhatsky
2026-08-04  7:02             ` haoqin huang
2026-08-04  8:30               ` Sergey Senozhatsky
2026-08-04  5:48           ` Sergey Senozhatsky
2026-08-04  7:13             ` haoqin huang
2026-08-04  8:28               ` Sergey Senozhatsky
2026-08-03 14:12         ` [PATCH v5 4/4] zram: reset per-priority params when changing algorithm before init Haoqin Huang
2026-08-04  9:38         ` [PATCH v6 0/5] zram: fix zstd error paths and add parameter validation Haoqin Huang
2026-08-04  9:38           ` [PATCH v6 1/5] zram: do not release zstd global params from error paths Haoqin Huang
2026-08-04  9:38           ` [PATCH v6 2/5] zram: reject zero-size dictionary Haoqin Huang
2026-08-04  9:38           ` [PATCH v6 3/5] zram: add pr_fmt to backend files Haoqin Huang
2026-08-04  9:38           ` [PATCH v6 4/5] zram: validate parameters in each backend's setup_params Haoqin Huang
2026-08-04  9:38           ` [PATCH v6 5/5] zram: reset per-priority params when changing algorithm before init Haoqin Huang
2026-08-04  9:53           ` [PATCH v6 0/5] zram: fix zstd error paths and add parameter validation Sergey Senozhatsky
2026-08-04  9:55             ` Sergey Senozhatsky
2026-08-04 19:55           ` Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=amgB3pPhKEmFkMEQ@google.com \
    --to=senozhatsky@chromium.org \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=dsterba@suse.com \
    --cc=haoqinhuang7@gmail.com \
    --cc=haoqinhuang@tencent.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=minchan@kernel.org \
    --cc=rongwei.wrw@gmail.com \
    --cc=terrelln@fb.com \
    --cc=zigiwang@tencent.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome