From: Andrew Morton <akpm@linux-foundation.org>
To: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: Karl Mehltretter <kmehltretter@gmail.com>,
Mark Fasheh <mark@fasheh.com>, Joel Becker <jlbec@evilplan.org>,
Cen Zhang <zzzccc427@gmail.com>,
ocfs2-devel@lists.linux.dev, linux-kernel@vger.kernel.org,
Sashiko <sashiko-bot@kernel.org>
Subject: Re: [PATCH] ocfs2/cluster: hold a reference on the heartbeat thread
Date: Wed, 23 Sep 2026 14:22:26 -0700 [thread overview]
Message-ID: <20260923142226.9a4d0eb4c71128b34e9aa10c@linux-foundation.org> (raw)
In-Reply-To: <e06390dc-fdfb-4bad-85ba-6baf361fac18@linux.alibaba.com>
On Wed, 23 Sep 2026 10:45:10 +0800 Joseph Qi <joseph.qi@linux.alibaba.com> wrote:
>
>
> On 9/23/26 9:01 AM, Karl Mehltretter wrote:
> > Since commit 688bc88e2046 ("ocfs2/cluster: keep heartbeat local node
> > stable"), o2hb_thread() leaves its loop and returns when the local node
> > changes, for example after "echo 0 > node/<name>/local". The thread
> > was started with kthread_run() and nothing holds a reference to its
> > task_struct, so the task is freed once it exits, while reg->hr_task
> > still points to it.
> >
> > Reading the region's pid attribute then reads the freed task, and
> > removing the region calls kthread_stop() on it:
> >
> > BUG: KASAN: slab-use-after-free in o2hb_region_pid_show+0xb3/0xc0
> > refcount_t: addition on 0; use-after-free.
> > Oops: Oops: 0000 [#1] SMP KASAN NOPTI
> > RIP: 0010:kthread_stop+0xb1/0x390
> >
> > The thread could already return by itself before, when heartbeat start
> > was aborted or on an unclean stop, but the local node change makes it
> > reachable from userspace at any time.
> >
> > Create the thread parked, take a reference on it and only then wake it,
>
> Just a wording nit. kthread_create() doesn't leave the thread parked in
> the kthread_park() sense. __kthread_parkme() only runs after the first
> wake_up_process(), so "parked" here may be a little confused.
I simply did s/parked //.
> The change looks fine to me.
> Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Thanks as always.
prev parent reply other threads:[~2026-09-23 21:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-23 1:01 Karl Mehltretter
2026-09-23 2:45 ` Joseph Qi
2026-09-23 21:22 ` Andrew Morton [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=20260923142226.9a4d0eb4c71128b34e9aa10c@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=jlbec@evilplan.org \
--cc=joseph.qi@linux.alibaba.com \
--cc=kmehltretter@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark@fasheh.com \
--cc=ocfs2-devel@lists.linux.dev \
--cc=sashiko-bot@kernel.org \
--cc=zzzccc427@gmail.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
all inboxes | Powered by JetHome®