zram: fix zstd dict use-after-free on per-CPU error path#1015
Open
blktests-ci[bot] wants to merge 3 commits into
Open
zram: fix zstd dict use-after-free on per-CPU error path#1015blktests-ci[bot] wants to merge 3 commits into
blktests-ci[bot] wants to merge 3 commits into
Conversation
Author
|
Upstream branch: 4edcdef |
4cc45a3 to
90ffd56
Compare
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>
Author
|
Upstream branch: dc59e4f |
6789bbe to
0c0050f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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