Skip to content

zram: fix zstd dict use-after-free on per-CPU error path#1015

Open
blktests-ci[bot] wants to merge 3 commits into
linus-master_basefrom
series/1117398=>linus-master
Open

zram: fix zstd dict use-after-free on per-CPU error path#1015
blktests-ci[bot] wants to merge 3 commits into
linus-master_basefrom
series/1117398=>linus-master

Conversation

@blktests-ci

@blktests-ci blktests-ci Bot commented Jun 27, 2026

Copy link
Copy Markdown

Pull request for series with
subject: zram: fix zstd dict use-after-free on per-CPU error path
version: 1
url: https://patchwork.kernel.org/project/linux-block/list/?series=1117398

@blktests-ci

blktests-ci Bot commented Jun 27, 2026

Copy link
Copy Markdown
Author

Upstream branch: 4edcdef
series: https://patchwork.kernel.org/project/linux-block/list/?series=1117398
version: 1

Haoqin Huang added 3 commits June 29, 2026 17:40
zstd_setup_params() creates global cdict and ddict stored in
params->drv_data, shared across all per-CPU contexts. When a
per-CPU zstd_create() failed, its error path called
zstd_release_params() which freed those shared objects while
other per-CPU contexts might already hold references to them.

Remove the premature zstd_release_params() from the per-CPU
error path, the global cdict/ddict are properly released later
by zstd_release_params(), called from zcomp_init()'s cleanup
or from zcomp_destroy().

Fixes: 6a559ec ("zram: add dictionary support to zstd backend")
Signed-off-by: Haoqin Huang <haoqinhuang@tencent.com>
Reviewed-by: Rongwei Wang <zigiwang@tencent.com>
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.

Signed-off-by: Haoqin Huang <haoqinhuang@tencent.com>
Reviewed-by: Rongwei Wang <zigiwang@tencent.com>
Parameters validated against one algorithm may be invalid for another
(e.g. lz4 accepts level=65535 but zstd does not).  Although algorithm
changes are blocked after disksize is set, they are allowed before
device initialization.  Reset per-priority params on algorithm change
so that stale parameters do not silently carry over.

Signed-off-by: Haoqin Huang <haoqinhuang@tencent.com>
Reviewed-by: Rongwei Wang <zigiwang@tencent.com>
@blktests-ci

blktests-ci Bot commented Jun 29, 2026

Copy link
Copy Markdown
Author

Upstream branch: dc59e4f
series: https://patchwork.kernel.org/project/linux-block/list/?series=1117398
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1117398=>linus-master branch from 6789bbe to 0c0050f Compare June 29, 2026 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants