From: Bjorn Andersson <andersson@kernel.org>
To: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Cc: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>,
Mathieu Poirier <mathieu.poirier@linaro.org>,
Shengjiu Wang <shengjiu.wang@nxp.com>,
Fernando Guzman Lugo <fernando.lugo@ti.com>,
Ohad Ben-Cohen <ohad@wizery.com>,
linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] remoteproc: Prevent crash handling to race with rproc_del()
Date: Thu, 23 Jul 2026 17:29:02 -0500 [thread overview]
Message-ID: <amKTZInKqMX48PWE@baldur> (raw)
In-Reply-To: <fffb231d-32a4-482d-91d1-b6932d16de59@oss.qualcomm.com>
On Thu, Jul 23, 2026 at 12:09:52PM +0200, Konrad Dybcio wrote:
> On 7/23/26 5:52 AM, Bjorn Andersson wrote:
> > There's no synchronization between rproc_crash_handler_work() and
> > rproc_del(), as such it's possible for a driver to be removed while
> > crash-handler work is scheduled, or even executing - resulting in
> > use-after-free issues.
>
> [...]
>
> > + spin_lock_irqsave(&rproc->crash_handler_lock, flags);
> > + if (READ_ONCE(rproc->deleting)) {
> > + spin_unlock_irqrestore(&rproc->crash_handler_lock, flags);
> > + return;
> > + }
> > +
> > /* Prevent suspend while the remoteproc is being recovered */
> > pm_stay_awake(rproc->dev.parent);
> > + queue_work(rproc_recovery_wq, &rproc->crash_handler);
> > + spin_unlock_irqrestore(&rproc->crash_handler_lock, flags);
> >
> > dev_err(&rproc->dev, "crash detected in %s: type %s\n",
> > rproc->name, rproc_crash_to_string(type));
>
> GPT reported that the rproc may be gone/deleting at the time of
> this print since it's outside the lock, so it's not a given that
> rproc->dev and rproc->name are valid (although the window is pretty
> slim..)
>
rproc->dev will be a valid object as long as the caller is holding a
reference to the rproc device (explicitly through rproc_get_by_phandle()
or implicitly through the device hierarchy), so there's no problem
there.
rproc->name has two different life cycles:
1) rproc_alloc(name) with name living on the heap or stack, will result
in `name` being owned by the rproc->dev life cycle and hence there's no
problem - as long as adequate references are held.
2) rproc_alloc(name) with name being a constant, here the rproc context
will hold a reference to the name in constant memory, and rmmod might
in this window have unmapped that constant.
So, the case when `name` is referencing a constant is a possible
problem, but unrelated to this patch.
Regards,
Bjorn
next prev parent reply other threads:[~2026-07-23 22:29 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-23 3:52 [PATCH 0/3] remoteproc: Improve removal of remoteproc drivers Bjorn Andersson
2026-07-23 3:52 ` [PATCH 1/3] remoteproc: Allow shutdown of crashed processors Bjorn Andersson
2026-07-23 9:34 ` Konrad Dybcio
2026-07-23 10:00 ` Mukesh Ojha
2026-07-23 3:52 ` [PATCH 2/3] remoteproc: Prevent crash handling to race with rproc_del() Bjorn Andersson
2026-07-23 10:09 ` Konrad Dybcio
2026-07-23 15:16 ` Mukesh Ojha
2026-07-23 22:29 ` Bjorn Andersson [this message]
2026-07-23 14:47 ` Mukesh Ojha
2026-07-23 15:19 ` Mukesh Ojha
2026-07-23 3:52 ` [PATCH 3/3] remoteproc: Force shutdown during device removal Bjorn Andersson
2026-07-23 9:59 ` Konrad Dybcio
2026-07-23 10:54 ` Konrad Dybcio
2026-07-23 16:12 ` Mukesh Ojha
2026-07-23 22:16 ` Bjorn Andersson
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=amKTZInKqMX48PWE@baldur \
--to=andersson@kernel.org \
--cc=bjorn.andersson@oss.qualcomm.com \
--cc=fernando.lugo@ti.com \
--cc=konrad.dybcio@oss.qualcomm.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=ohad@wizery.com \
--cc=shengjiu.wang@nxp.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