From: sashiko-bot@kernel.org
To: "Sumit Garg" <sumit.garg@kernel.org>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v8 04/14] remoteproc: qcom_q6v5_pas: Switch over to generic PAS TZ APIs
Date: Sat, 27 Jun 2026 13:42:32 +0000 [thread overview]
Message-ID: <20260627134232.EAC9C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260626133440.692849-5-sumit.garg@kernel.org>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
New issues:
- [High] Removing the `qcom_scm_is_available()` check in `qcom_pas_probe()` exposes the driver to a NULL pointer dereference in `qcom_scm_assign_mem()`.
Pre-existing issues:
- [High] `pas->dtb_firmware` is leaked on the success path because `release_firmware()` is never called.
- [High] If `qcom_pas_start()` fails after authenticating the DTB PAS, it never invokes `qcom_pas_shutdown()` for the DTB PAS, leaving it permanently running/authenticated in TrustZone.
--
commit 410365720c51e458aee76cb1ae2177033dc208d2
Author: Sumit Garg <sumit.garg@oss.qualcomm.com>
remoteproc: qcom_q6v5_pas: Switch over to generic PAS TZ APIs
This commit switches the qcom_q6v5_pas client driver over to use generic PAS
TZ APIs. This allows support for multiple TZ implementation backends, and
updates the MDT loader PAS dependencies to prevent build issues.
> diff --git a/drivers/remoteproc/qcom_q6v5_pas.c b/drivers/remoteproc/qcom_q6v5_pas.c
> index 808e9609988d3..9eb1c4f6c2ab4 100644
> --- a/drivers/remoteproc/qcom_q6v5_pas.c
> +++ b/drivers/remoteproc/qcom_q6v5_pas.c
[ ... ]
> @@ -225,9 +226,9 @@ static int qcom_pas_load(struct rproc *rproc, const struct firmware *fw)
> pas->firmware = fw;
>
> if (pas->lite_pas_id)
> - qcom_scm_pas_shutdown(pas->lite_pas_id);
> + qcom_pas_shutdown(pas->lite_pas_id);
> if (pas->lite_dtb_pas_id)
> - qcom_scm_pas_shutdown(pas->lite_dtb_pas_id);
> + qcom_pas_shutdown(pas->lite_dtb_pas_id);
>
> if (pas->dtb_pas_id) {
> ret = request_firmware(&pas->dtb_firmware, pas->dtb_firmware_name, pas->dev);
[ ... ]
> ret = qcom_mdt_pas_load(pas->dtb_pas_ctx, pas->dtb_firmware,
> pas->dtb_firmware_name, pas->dtb_mem_region,
> &pas->dtb_mem_reloc);
> if (ret)
> goto release_dtb_metadata;
> }
>
> return 0;
[Severity: High]
This is a pre-existing issue, but does this code leak the DTB firmware buffer
on the success path?
If request_firmware() successfully allocates pas->dtb_firmware, it doesn't
appear to be freed with release_firmware() here before returning 0, nor
is it released anywhere in the teardown callbacks like qcom_pas_stop() or
qcom_pas_unprepare().
Could this lead to memory exhaustion if the remoteproc is repeatedly started
and stopped via sysfs?
>
> release_dtb_metadata:
> - qcom_scm_pas_metadata_release(pas->dtb_pas_ctx);
> + qcom_pas_metadata_release(pas->dtb_pas_ctx);
> release_firmware(pas->dtb_firmware);
>
> return ret;
[ ... ]
> @@ -307,7 +308,7 @@ static int qcom_pas_start(struct rproc *rproc)
> if (ret)
> goto disable_px_supply;
>
> - ret = qcom_scm_pas_prepare_and_auth_reset(pas->dtb_pas_ctx);
> + ret = qcom_pas_prepare_and_auth_reset(pas->dtb_pas_ctx);
> if (ret) {
> dev_err(pas->dev,
> "failed to authenticate dtb image and release reset\n");
> @@ -326,7 +327,7 @@ static int qcom_pas_start(struct rproc *rproc)
> if (ret)
> goto release_pas_metadata;
[ ... ]
> unmap_carveout:
> qcom_pas_unmap_carveout(rproc, pas->mem_phys, pas->mem_size);
> release_pas_metadata:
> - qcom_scm_pas_metadata_release(pas->pas_ctx);
> + qcom_pas_metadata_release(pas->pas_ctx);
> if (pas->dtb_pas_id)
> - qcom_scm_pas_metadata_release(pas->dtb_pas_ctx);
> + qcom_pas_metadata_release(pas->dtb_pas_ctx);
[Severity: High]
This isn't a bug introduced by this patch, but if a failure occurs after the
DTB PAS is successfully authenticated, could this strand the TrustZone state?
If qcom_pas_prepare_and_auth_reset(pas->dtb_pas_ctx) succeeds, but a
subsequent step like qcom_mdt_pas_load() fails, the code jumps to the
release_pas_metadata label.
The error unwind doesn't seem to invoke qcom_pas_shutdown(pas->dtb_pas_id)
for the DTB PAS, which might leave the DTB PAS session permanently active in
TrustZone until the next reboot.
>
> unmap_dtb_carveout:
> if (pas->dtb_pas_id)
[ ... ]
> @@ -743,7 +744,7 @@ static int qcom_pas_probe(struct platform_device *pdev)
> if (!desc)
> return -EINVAL;
>
> - if (!qcom_scm_is_available())
> + if (!qcom_pas_is_available())
> return -EPROBE_DEFER;
>
> fw_name = desc->firmware_name;
[Severity: High]
By changing this dependency check from qcom_scm_is_available() to
qcom_pas_is_available(), is it possible to encounter a NULL pointer
dereference later in the probe sequence?
If the OP-TEE PAS backend is registered, qcom_pas_is_available() returns true,
allowing probe to proceed even if the qcom_scm driver is deferred or
unavailable.
Later in the sequence, the code calls:
qcom_pas_probe()
qcom_pas_assign_memory_region()
qcom_scm_assign_mem()
If qcom_scm_assign_mem() is called unconditionally when region_assign_count > 0,
it will attempt to use the __scm pointer to allocate TrustZone memory, which
might be NULL if the SCM driver isn't available.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260626133440.692849-1-sumit.garg@kernel.org?part=4
next prev parent reply other threads:[~2026-06-27 13:42 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-26 13:34 [PATCH v8 00/14] firmware: qcom: Add OP-TEE PAS service support Sumit Garg
2026-06-26 13:34 ` Sumit Garg via OP-TEE
2026-06-26 13:34 ` [PATCH v8 01/14] firmware: qcom: Add a generic PAS service Sumit Garg
2026-06-26 13:34 ` Sumit Garg via OP-TEE
2026-06-27 13:42 ` sashiko-bot
2026-06-26 13:34 ` [PATCH v8 02/14] firmware: qcom_scm: Migrate to " Sumit Garg
2026-06-26 13:34 ` Sumit Garg via OP-TEE
2026-06-26 17:05 ` Julian Braha
2026-06-27 13:42 ` sashiko-bot
2026-06-26 13:34 ` [PATCH v8 03/14] firmware: qcom: Add a PAS TEE service Sumit Garg
2026-06-26 13:34 ` Sumit Garg via OP-TEE
2026-06-27 13:42 ` sashiko-bot
2026-06-26 13:34 ` [PATCH v8 04/14] remoteproc: qcom_q6v5_pas: Switch over to generic PAS TZ APIs Sumit Garg via OP-TEE
2026-06-26 13:34 ` Sumit Garg
2026-06-27 13:42 ` sashiko-bot [this message]
2026-06-26 13:34 ` [PATCH v8 05/14] remoteproc: qcom_q6v5_mss: Switch " Sumit Garg via OP-TEE
2026-06-26 13:34 ` Sumit Garg
2026-06-27 13:42 ` sashiko-bot
2026-06-26 13:34 ` [PATCH v8 06/14] remoteproc: qcom_wcnss: " Sumit Garg via OP-TEE
2026-06-26 13:34 ` Sumit Garg
2026-06-27 13:42 ` sashiko-bot
2026-06-26 13:34 ` [PATCH v8 07/14] remoteproc: qcom: Select QCOM_PAS generic service Sumit Garg via OP-TEE
2026-06-26 13:34 ` Sumit Garg
2026-06-27 13:42 ` sashiko-bot
2026-06-26 13:34 ` [PATCH v8 08/14] drm/msm: Switch to generic PAS TZ APIs Sumit Garg via OP-TEE
2026-06-26 13:34 ` Sumit Garg
2026-06-27 13:42 ` sashiko-bot
2026-06-26 13:34 ` [PATCH v8 09/14] media: qcom: " Sumit Garg via OP-TEE
2026-06-26 13:34 ` Sumit Garg
2026-06-27 13:42 ` sashiko-bot
2026-06-26 13:34 ` [PATCH v8 10/14] media: qcom: Pass proper PAS ID to set_remote_state API Sumit Garg via OP-TEE
2026-06-26 13:34 ` Sumit Garg
2026-06-26 13:34 ` [PATCH v8 11/14] net: ipa: Switch to generic PAS TZ APIs Sumit Garg
2026-06-26 13:34 ` Sumit Garg via OP-TEE
2026-06-27 13:42 ` sashiko-bot
2026-06-26 13:34 ` [PATCH v8 12/14] wifi: ath12k: " Sumit Garg
2026-06-26 13:34 ` Sumit Garg via OP-TEE
2026-06-27 13:42 ` sashiko-bot
2026-06-26 13:34 ` [PATCH v8 13/14] firmware: qcom_scm: Remove SCM PAS wrappers Sumit Garg
2026-06-26 13:34 ` Sumit Garg via OP-TEE
2026-06-26 13:34 ` [PATCH v8 14/14] MAINTAINERS: Add maintainer entry for Qualcomm PAS TZ service Sumit Garg
2026-06-26 13:34 ` Sumit Garg via OP-TEE
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=20260627134232.EAC9C1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=sumit.garg@kernel.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 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.