dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sumit Garg" <sumit.garg@kernel.org>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v8 05/14] remoteproc: qcom_q6v5_mss: Switch to generic PAS TZ APIs
Date: Sat, 27 Jun 2026 13:42:27 +0000	[thread overview]
Message-ID: <20260627134228.66A631F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260626133440.692849-6-sumit.garg@kernel.org>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:

New issues:
- [High] Replacing `qcom_scm_is_available()` with `qcom_pas_is_available()` removes the SCM dependency check, leading to a NULL pointer dereference during memory protection.
- [High] The generic PAS API removes the hard module dependency on the backend provider, exposing client drivers to a TOCTOU race condition and Use-After-Free.

Pre-existing issues:
- [High] Missing initialization of `need_pas_mem_setup` makes PAS memory setup silently skipped.
--

commit 286e03507d8f96a33a10d31ad2cb432432734d78
Author: Sumit Garg <sumit.garg@oss.qualcomm.com>
Subject: remoteproc: qcom_q6v5_mss: Switch to generic PAS TZ APIs

This commit switches the qcom_q6v5_mss client driver to use the generic PAS
TZ APIs. This enables support for multiple TZ implementation backends, such
as QTEE based SCM PAS service and OP-TEE based PAS service.

> diff --git a/drivers/remoteproc/qcom_q6v5_mss.c b/drivers/remoteproc/qcom_q6v5_mss.c
> index ae78f5c7c1b69..96888007faa88 100644
> --- a/drivers/remoteproc/qcom_q6v5_mss.c
> +++ b/drivers/remoteproc/qcom_q6v5_mss.c
[ ... ]
> @@ -1480,7 +1481,7 @@ static int q6v5_mpss_load(struct q6v5 *qproc)
>  	}
>  
>  	if (qproc->need_pas_mem_setup) {

[Severity: High]
This is a pre-existing issue, but I noticed that need_pas_mem_setup is never
populated from the match descriptor in q6v5_probe(). Since qproc is
allocated via devm_rproc_alloc() and zero-initialized, this boolean will
always be false.

Does this prevent qcom_pas_mem_setup() from ever being called even on
platforms that require it?

> -		ret = qcom_scm_pas_mem_setup(MPSS_PAS_ID, qproc->mpss_phys, qproc->mpss_size);
> +		ret = qcom_pas_mem_setup(MPSS_PAS_ID, qproc->mpss_phys, qproc->mpss_size);

[Severity: High]
Does this new generic PAS API safely handle backend module unloading?

Previously, calling qcom_scm_pas_mem_setup() created a hard symbol
dependency, preventing the backend module from being unloaded. The generic
framework uses a lockless ops_ptr without acquiring module references:

drivers/firmware/qcom/qcom_pas.c:qcom_pas_mem_setup() {
    if (!ops_ptr)
        return -ENODEV;

    return ops_ptr->mem_setup(ops_ptr->dev, pas_id, addr, size);
}

Could the backend module be unloaded after the ops_ptr check but before or
during the mem_setup() call, leading to a use-after-free or NULL pointer
dereference?

>  		if (ret) {
>  			dev_err(qproc->dev,
>  				"setting up mpss memory failed: %d\n", ret);
[ ... ]
> @@ -2077,7 +2078,7 @@ static int q6v5_probe(struct platform_device *pdev)
>  	if (!desc)
>  		return -EINVAL;
>  
> -	if (desc->need_mem_protection && !qcom_scm_is_available())
> +	if (desc->need_mem_protection && !qcom_pas_is_available())

[Severity: High]
Is it safe to replace the SCM availability check with the PAS availability
check here?

If need_mem_protection is true, q6v5_mpss_load() will unconditionally call
q6v5_xfer_mem_ownership(), which eventually relies on qcom_scm_assign_mem()
and dereferences the internal SCM structures.

If a non-SCM PAS backend is available but SCM is uninitialized, the PAS
check will succeed here, but the subsequent memory protection operations
will trigger a NULL pointer dereference.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260626133440.692849-1-sumit.garg@kernel.org?part=5

  reply	other threads:[~2026-06-27 13:42 UTC|newest]

Thread overview: 48+ 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 ` [PATCH v8 01/14] firmware: qcom: Add a generic PAS service Sumit Garg
2026-06-27 13:42   ` sashiko-bot
2026-06-30 12:14   ` Konrad Dybcio
2026-07-01  7:17     ` Sumit Garg
2026-06-30 12:21   ` Konrad Dybcio
2026-06-26 13:34 ` [PATCH v8 02/14] firmware: qcom_scm: Migrate to " Sumit Garg
2026-06-26 17:05   ` Julian Braha
2026-07-01  7:21     ` Sumit Garg
2026-06-27 13:42   ` sashiko-bot
2026-06-30 12:26   ` Konrad Dybcio
2026-06-26 13:34 ` [PATCH v8 03/14] firmware: qcom: Add a PAS TEE service Sumit Garg
2026-06-27 13:42   ` sashiko-bot
2026-07-01  7:33     ` Sumit Garg
2026-06-26 13:34 ` [PATCH v8 04/14] remoteproc: qcom_q6v5_pas: Switch over to generic PAS TZ APIs Sumit Garg
2026-06-27 13:42   ` sashiko-bot
2026-06-30 12:34   ` Konrad Dybcio
2026-07-01  7:35     ` Sumit Garg
2026-06-26 13:34 ` [PATCH v8 05/14] remoteproc: qcom_q6v5_mss: Switch " Sumit Garg
2026-06-27 13:42   ` sashiko-bot [this message]
2026-06-30 12:35   ` Konrad Dybcio
2026-06-26 13:34 ` [PATCH v8 06/14] remoteproc: qcom_wcnss: " Sumit Garg
2026-06-27 13:42   ` sashiko-bot
2026-06-30 12:36   ` Konrad Dybcio
2026-06-26 13:34 ` [PATCH v8 07/14] remoteproc: qcom: Select QCOM_PAS generic service Sumit Garg
2026-06-27 13:42   ` sashiko-bot
2026-06-30 12:37   ` Konrad Dybcio
2026-07-01  5:36     ` Sumit Garg
2026-06-26 13:34 ` [PATCH v8 08/14] drm/msm: Switch to generic PAS TZ APIs Sumit Garg
2026-06-27 13:42   ` sashiko-bot
2026-06-30 12:39   ` Konrad Dybcio
2026-06-26 13:34 ` [PATCH v8 09/14] media: qcom: " Sumit Garg
2026-06-27 13:42   ` sashiko-bot
2026-06-30 12:41   ` Konrad Dybcio
2026-06-26 13:34 ` [PATCH v8 10/14] media: qcom: Pass proper PAS ID to set_remote_state API Sumit Garg
2026-06-30 12:42   ` Konrad Dybcio
2026-07-01  7:44     ` Sumit Garg
2026-07-01 11:01       ` Konrad Dybcio
2026-07-01 12:19         ` Sumit Garg
2026-06-26 13:34 ` [PATCH v8 11/14] net: ipa: Switch to generic PAS TZ APIs Sumit Garg
2026-06-27 13:42   ` sashiko-bot
2026-06-30 12:43   ` Konrad Dybcio
2026-06-26 13:34 ` [PATCH v8 12/14] wifi: ath12k: " Sumit Garg
2026-06-27 13:42   ` sashiko-bot
2026-06-30 12:44   ` Konrad Dybcio
2026-06-26 13:34 ` [PATCH v8 13/14] firmware: qcom_scm: Remove SCM PAS wrappers Sumit Garg
2026-06-30 12:45   ` Konrad Dybcio
2026-06-26 13:34 ` [PATCH v8 14/14] MAINTAINERS: Add maintainer entry for Qualcomm PAS TZ service Sumit Garg

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=20260627134228.66A631F000E9@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox