All of 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 06/14] remoteproc: qcom_wcnss: Switch to generic PAS TZ APIs
Date: Sat, 27 Jun 2026 13:42:31 +0000	[thread overview]
Message-ID: <20260627134231.729921F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260626133440.692849-7-sumit.garg@kernel.org>

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

New issues:
- [High] The generic PAS API functions in qcom_pas.c suffer from a TOCTOU race condition when reading the global ops_ptr, leading to a potential NULL pointer dereference.

Pre-existing issues:
- [High] Missing cleanup of SMD and Sysmon subdevices on wcnss_probe() error paths leads to resource leaks and Use-After-Free vulnerabilities.
- [High] Removing iris before deleting rproc in wcnss_remove() creates a Use-After-Free race condition.
- [High] Missing reinit_completion() causes spurious success on subsequent remoteproc starts or stops.
- [High] Infinite polling loop in wcnss_configure_iris() can cause kernel hangs.
--

commit f90353d8289b80221557c481e264c0861b3fde18
Author: Sumit Garg <sumit.garg@oss.qualcomm.com>

remoteproc: qcom_wcnss: Switch to generic PAS TZ APIs

This commit switches the qcom_wcnss client driver to use the generic PAS TZ
APIs. This allows support for multiple TZ implementations like QTEE or OP-TEE.

> diff --git a/drivers/remoteproc/qcom_wcnss.c b/drivers/remoteproc/qcom_wcnss.c
> index 4add9037dbd5a..0dbdd18ab3dd9 100644
> --- a/drivers/remoteproc/qcom_wcnss.c
> +++ b/drivers/remoteproc/qcom_wcnss.c
> @@ -257,7 +257,7 @@ static int wcnss_start(struct rproc *rproc)
>  	wcnss_indicate_nv_download(wcnss);
>  	wcnss_configure_iris(wcnss);

[Severity: High]
This is a pre-existing issue, but can the infinite polling loops inside
wcnss_configure_iris() cause a hard kernel hang if the hardware is wedged?

Inside wcnss_configure_iris(), we poll hardware registers without a timeout:

drivers/remoteproc/qcom_wcnss.c:wcnss_configure_iris() {
    ...
    while (readl(wcnss->pmu_cfg) & WCNSS_PMU_IRIS_RESET_STS)
        cpu_relax();
    ...
    while (readl(wcnss->pmu_cfg) & WCNSS_PMU_IRIS_XO_CFG_STS)
        cpu_relax();
    ...
}

Could this lead to a denial of service if the register returns 0xffffffff or
remains unresponsive?

>  
> -	ret = qcom_scm_pas_auth_and_reset(WCNSS_PAS_ID);
> +	ret = qcom_pas_auth_and_reset(WCNSS_PAS_ID);

[Severity: High]
Does this new qcom_pas_auth_and_reset() call introduce a race condition?

Looking at the generic PAS API implementation in qcom_pas.c:

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

    return ops_ptr->auth_and_reset(ops_ptr->dev, pas_id);
}

Since ops_ptr is checked and then dereferenced without READ_ONCE() or locks,
could a concurrent backend module unload set ops_ptr to NULL between the check
and the dereference, causing a kernel panic?

[Severity: High]
This is a pre-existing issue, but does wcnss_start() risk spurious success
on subsequent starts if a previous wait timed out?

There is a call to wait_for_completion_timeout(&wcnss->start_done, ...) right
below this in wcnss_start(). If it times out, but a delayed ready interrupt
later calls complete(&wcnss->start_done), the next wcnss_start() could
instantly succeed without actually waiting for the firmware.

Should reinit_completion() be called before initiating the wait in both
wcnss_start() and wcnss_stop()?

>  	if (ret) {
>  		dev_err(wcnss->dev,
>  			"failed to authenticate image and release reset\n");

[ ... ]

> @@ -557,10 +557,10 @@ static int wcnss_probe(struct platform_device *pdev)
>  
>  	data = of_device_get_match_data(&pdev->dev);
>  
> -	if (!qcom_scm_is_available())
> +	if (!qcom_pas_is_available())
>  		return -EPROBE_DEFER;

[Severity: High]
This is a pre-existing issue, but do the error paths in wcnss_probe() leak
the SMD and Sysmon subdevices?

In wcnss_probe(), qcom_add_sysmon_subdev() allocates memory and registers a
notifier to a global chain. If a subsequent step like qcom_iris_probe()
fails, the error path jumps to remove_iris or detach_pds:

drivers/remoteproc/qcom_wcnss.c:wcnss_probe() {
    ...
remove_iris:
    qcom_iris_remove(wcnss->iris);
detach_pds:
    wcnss_release_pds(wcnss);

    return ret;
}

This path fails to call qcom_remove_sysmon_subdev() and
qcom_remove_smd_subdev(). Could this leave the sysmon object in the global
notifier chain, leading to a use-after-free when the notifier triggers?

[Severity: High]
This is a pre-existing issue, but does wcnss_remove() have a use-after-free
race condition by freeing the iris object before stopping the remoteproc?

drivers/remoteproc/qcom_wcnss.c:wcnss_remove() {
    ...
    qcom_iris_remove(wcnss->iris);
    rproc_del(wcnss->rproc);
    ...
}

Because rproc_del() hasn't stopped the remoteproc yet, userspace could
concurrently trigger wcnss_start(). Since wcnss_start() checks
if (!wcnss->iris), which passes because the pointer is freed but not nulled,
it then calls qcom_iris_enable(wcnss->iris) on freed memory.

Should rproc_del() be called before qcom_iris_remove() to prevent this?

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

  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
2026-06-26 13:34   ` Sumit Garg via OP-TEE
2026-06-27 13:42   ` sashiko-bot
2026-06-26 13:34 ` [PATCH v8 05/14] remoteproc: qcom_q6v5_mss: Switch " 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 06/14] remoteproc: qcom_wcnss: " Sumit Garg
2026-06-26 13:34   ` Sumit Garg via OP-TEE
2026-06-27 13:42   ` sashiko-bot [this message]
2026-06-26 13:34 ` [PATCH v8 07/14] remoteproc: qcom: Select QCOM_PAS generic 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 08/14] drm/msm: 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 09/14] media: qcom: " 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 10/14] media: qcom: Pass proper PAS ID to set_remote_state API Sumit Garg
2026-06-26 13:34   ` Sumit Garg via OP-TEE
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=20260627134231.729921F000E9@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.