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 1/3] zram: fix zstd dict use-after-free on per-CPU error path
Date: Tue, 28 Jul 2026 10:21:37 +0900 [thread overview]
Message-ID: <amgD54HG-KPDVpP9@google.com> (raw)
In-Reply-To: <CAEjiKSntJKSaEeQe8YbtNe=6574=kx-y4CXKph6u_F04O=3kFQ@mail.gmail.com>
On (26/07/28 00:06), haoqin huang wrote:
> > > 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.
> >
> > zstd_release_params() sets ->drv_data to NULL so we can free params
> > only once. In addition, "while other per-CPU contexts might
> > already hold references to them" -- other CPUs cannot do anything
> > with those params, the device is not setup and we cannot handle any
> > IO requests, right? There is no double-free nor UAF there as far
> > as I can tell.
> >
>
> You're right. On the init failure path, drv_data=NULL prevents a
> double-free, no IO is ever submitted, and cpuhp_rollback_install()
> properly tears down the per-CPU contexts that succeeded (which only
> calls zstd_destroy(), never touching drv_data). So the system doesn't
> crash or leak -- it just means the global cdict/ddict get released by
> the per-CPU error path rather than by zcomp_init()'s cleanup label.
> The original commit message was poorly worded, I'll fix it.
>
> > > 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: 6a559ecd6e7e ("zram: add dictionary support to zstd backend")
> >
> > What exactly does this fix?
>
> It's more of a correctness / ownership fix than a crash fix.
OK, fair. Agreed, let's rewrite commit message and then we are good
to go.
prev parent reply other threads:[~2026-07-28 1:21 UTC|newest]
Thread overview: 12+ 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
2026-07-28 1:27 ` Sergey Senozhatsky
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 [this message]
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=amgD54HG-KPDVpP9@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