From: Joshua Hahn <joshua.hahnjy@gmail.com>
To: Joshua Hahn <joshua.hahnjy@gmail.com>
Cc: Minchan Kim <minchan@kernel.org>, Michael Fara <mjfara@gmail.com>,
senozhatsky@chromium.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, akpm@linux-foundation.org
Subject: Re: [PATCH] mm/zsmalloc: fix NULL pointer dereference in get_next_zpdesc
Date: Mon, 9 Feb 2026 15:16:52 -0800 [thread overview]
Message-ID: <20260209231652.1806289-1-joshua.hahnjy@gmail.com> (raw)
In-Reply-To: <20260209225018.1541260-1-joshua.hahnjy@gmail.com>
I just noticed that Minchan wasn't Cc-ed in the patch. Adding him to the
conversation here.
On Mon, 9 Feb 2026 14:50:16 -0800 Joshua Hahn <joshua.hahnjy@gmail.com> wrote:
> On Mon, 9 Feb 2026 19:32:57 +0000 Michael Fara <mjfara@gmail.com> wrote:
>
> Hello Michael,
>
> I hope you are doing well! Thank you for the patch. I'm not entirely sure if
> the race condition that you note here is correct, and also if this is the
> right fix.
>
> > get_next_zpdesc() calls get_zspage() which unconditionally dereferences
> > zpdesc->zspage without a NULL check. This causes a kernel oops when
> > zpdesc->zspage has been set to NULL by reset_zpdesc() during a race
> > between zspage destruction and page compaction/migration.
[...snip...]
Should we add a Fixes tag here as well?
> > Signed-off-by: Michael Fara <mjfara@gmail.com>
> > ---
> > mm/zsmalloc.c | 14 +++++++++++++-
> > 1 file changed, 13 insertions(+), 1 deletion(-)
> >
> > diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
> > --- a/mm/zsmalloc.c
> > +++ b/mm/zsmalloc.c
> > @@ -735,7 +735,19 @@ static struct zspage *get_zspage(struct zpdesc *zpdesc)
> >
> > static struct zpdesc *get_next_zpdesc(struct zpdesc *zpdesc)
> > {
> > - struct zspage *zspage = get_zspage(zpdesc);
> > + struct zspage *zspage = zpdesc->zspage;
> > +
> > + /*
> > + * If the backpointer is NULL, this zpdesc was already freed via
> > + * reset_zpdesc() by a racing async_free_zspage() while isolated
> > + * for compaction. See the TODO comment in zs_page_migrate().
> > + */
> > + if (unlikely(!zspage)) {
> > + WARN_ON_ONCE(1);
> > + return NULL;
> > + }
> > +
> > + BUG_ON(zspage->magic != ZSPAGE_MAGIC);
> >
> > if (unlikely(ZsHugePage(zspage)))
> > return NULL;
> > --
> > 2.39.0
next prev parent reply other threads:[~2026-02-09 23:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-09 19:32 Michael Fara
2026-02-09 22:50 ` Joshua Hahn
2026-02-09 23:16 ` Joshua Hahn [this message]
2026-02-18 5:56 ` Sergey Senozhatsky
2026-02-09 19:36 Michael Fara
2026-02-09 19:37 Michael Fara
2026-02-18 5:01 ` Sergey Senozhatsky
2026-02-18 5:46 ` Sergey Senozhatsky
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=20260209231652.1806289-1-joshua.hahnjy@gmail.com \
--to=joshua.hahnjy@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=mjfara@gmail.com \
--cc=senozhatsky@chromium.org \
/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