From: sashiko-bot@kernel.org
To: "Jingyi Wang" <jingyi.wang@oss.qualcomm.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v6 5/6] remoteproc: qcom: pas: Add late attach support for subsystems
Date: Tue, 19 May 2026 08:50:10 +0000 [thread overview]
Message-ID: <20260519085010.D8FA3C2BCB3@smtp.kernel.org> (raw)
In-Reply-To: <20260519-knp-soccp-v6-5-cf5d0e194b5f@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Critical] Calling `rproc_report_crash()` followed by returning an error from `.attach()` causes critical Use-After-Free vulnerabilities.
- [High] Returning `-EINVAL` when the subsystem is not ready breaks the intended fallback to offline boot and causes device probe failure.
- [Medium] The `handover_irq` is left enabled on multiple error paths, causing an unbalanced IRQ enablement depth.
--
commit 1111bc6bad772baf2e724e0d339a047f01859d2f
Author: Jingyi Wang <jingyi.wang@oss.qualcomm.com>
remoteproc: qcom: pas: Add late attach support for subsystems
This commit adds late attach support for subsystems brought out of reset by
early bootloaders. It introduces qcom_pas_attach() to check subsystem state
via SMP2P bits, reporting crashes or falling back to offline mode.
> diff --git a/drivers/remoteproc/qcom_q6v5_pas.c b/drivers/remoteproc/qcom_q6v5_pas.c
> --- a/drivers/remoteproc/qcom_q6v5_pas.c
> +++ b/drivers/remoteproc/qcom_q6v5_pas.c
[ ... ]
> @@ -510,6 +511,57 @@ static unsigned long qcom_pas_panic(struct rproc *rproc)
> return qcom_q6v5_panic(&pas->q6v5);
> }
>
> +static int qcom_pas_attach(struct rproc *rproc)
> +{
> + int ret;
> + struct qcom_pas *pas = rproc->priv;
> + bool ready_state;
> + bool crash_state;
> +
> + pas->q6v5.handover_issued = true;
> + enable_irq(pas->q6v5.handover_irq);
> +
> + pas->q6v5.running = true;
> + ret = irq_get_irqchip_state(pas->q6v5.fatal_irq,
> + IRQCHIP_STATE_LINE_LEVEL, &crash_state);
> +
> + if (ret)
> + goto disable_running;
If ret is non-zero, we jump to disable_running and return an error without
calling disable_irq(). Does this leave the handover_irq enabled?
Since the attach fails, the remoteproc core never calls the stop callback,
meaning qcom_q6v5_unprepare() is bypassed. This might permanently leak the
IRQ enable count.
> +
> + if (crash_state) {
> + dev_err(pas->dev, "Subsystem has crashed before driver probe\n");
> + rproc_report_crash(rproc, RPROC_FATAL_ERROR);
> + ret = -EINVAL;
> + goto disable_running;
> + }
Could calling rproc_report_crash() and then returning an error lead to
use-after-free conditions?
rproc_report_crash() asynchronously queues the crash_handler work on
rproc_recovery_wq. If auto_boot is true, the attach failure causes
rproc_add() to abort, and devres will free the rproc object. The queued
crash handler is not explicitly cancelled during cleanup, so it may
dereference the freed rproc memory when it executes.
If auto_boot is false, rproc isn't freed, but rproc_attach() cleans up its
failure by calling rproc_disable_iommu(), which frees rproc->domain. The
async crash handler later executes, fails to abort on the RPROC_DETACHED
state, sets the state to RPROC_CRASHED, and triggers recovery. The recovery
process calls rproc_stop() -> qcom_pas_stop() -> qcom_pas_unmap_carveout(),
which unconditionally dereferences the freed rproc->domain via
iommu_unmap().
Additionally, does this path leave the handover_irq enabled as well?
> +
> + ret = irq_get_irqchip_state(pas->q6v5.ready_irq,
> + IRQCHIP_STATE_LINE_LEVEL, &ready_state);
> +
> + if (ret)
> + goto disable_running;
> +
> + if (unlikely(!ready_state)) {
> + /*
> + * The bootloader may not support early boot, mark the state as
> + * RPROC_OFFLINE so that the PAS driver can load the firmware and
> + * start the remoteproc.
> + */
> + dev_err(pas->dev, "Failed to get subsystem ready interrupt\n");
> + pas->rproc->state = RPROC_OFFLINE;
> + disable_irq(pas->q6v5.handover_irq);
> + ret = -EINVAL;
> + goto disable_running;
> + }
Does returning -EINVAL here prevent the intended fallback to offline boot?
If the device has auto_boot enabled, rproc_add() treats the -EINVAL from
the auto-boot attempt as a fatal error. It executes goto rproc_remove_dev,
which destroys the remoteproc device entirely and fails the driver probe.
This makes the intended fallback impossible, as the device is never
registered.
> +
> + return 0;
> +
> +disable_running:
> + pas->q6v5.running = false;
> +
> + return ret;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260519-knp-soccp-v6-0-cf5d0e194b5f@oss.qualcomm.com?part=5
next prev parent reply other threads:[~2026-05-19 8:50 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-19 7:24 [PATCH v6 0/6] Add binding and driver for Kaanapali SoCCP Jingyi Wang
2026-05-19 7:24 ` [PATCH v6 1/6] dt-bindings: remoteproc: qcom: cleanup qcom,adsp.yaml Jingyi Wang
2026-05-19 7:24 ` [PATCH v6 2/6] dt-bindings: remoteproc: qcom: move interrupts and interrupt-names list out of pas-common Jingyi Wang
2026-05-19 7:24 ` [PATCH v6 3/6] dt-bindings: remoteproc: qcom: Document pas for SoCCP on Kaanapali and Glymur platforms Jingyi Wang
2026-05-19 8:05 ` sashiko-bot
2026-05-19 8:45 ` Shawn Guo
2026-05-20 2:44 ` Jingyi Wang
2026-05-19 7:24 ` [PATCH v6 4/6] dt-bindings: remoteproc: qcom: Document pas for SoCCP on Hawi SoC Jingyi Wang
2026-05-19 9:54 ` Rob Herring (Arm)
2026-05-20 4:11 ` Jingyi Wang
2026-05-19 7:24 ` [PATCH v6 5/6] remoteproc: qcom: pas: Add late attach support for subsystems Jingyi Wang
2026-05-19 8:33 ` Shawn Guo
2026-05-19 8:50 ` sashiko-bot [this message]
2026-05-20 8:27 ` Mukesh Ojha
2026-05-20 10:18 ` Shawn Guo
2026-05-21 3:42 ` Jingyi Wang
2026-05-21 11:22 ` Mukesh Ojha
2026-05-22 12:07 ` Stephan Gerhold
2026-05-25 4:30 ` Shawn Guo
2026-06-02 7:49 ` Jingyi Wang
2026-05-19 7:24 ` [PATCH v6 6/6] remoteproc: qcom_q6v5_pas: Add SoCCP node on Kaanapali Jingyi Wang
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=20260519085010.D8FA3C2BCB3@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jingyi.wang@oss.qualcomm.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.