From: sashiko-bot@kernel.org
To: "Sumit Garg" <sumit.garg@kernel.org>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v8 07/14] remoteproc: qcom: Select QCOM_PAS generic service
Date: Sat, 27 Jun 2026 13:42:30 +0000 [thread overview]
Message-ID: <20260627134230.B06C61F00ADB@smtp.kernel.org> (raw)
In-Reply-To: <20260626133440.692849-8-sumit.garg@kernel.org>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Heap buffer overflow (OOB write) and undefined behavior in qcom_pas_tee_get_rsc_table due to missing size bounds and NULL validation.
- [High] Out-of-bounds read in qcom_pas_tee_get_rsc_table during kmemdup.
- [High] State corruption due to unconditional unregistration of PAS ops.
--
commit b487f397efddfdc143f4e42a9e7644cc3aeb39da
Author: Sumit Garg <sumit.garg@oss.qualcomm.com>
remoteproc: qcom: Select QCOM_PAS generic service
Select PAS generic service driver to enable support for multiple PAS
backends like OP-TEE in addition to SCM.
> diff --git a/drivers/firmware/qcom/qcom_pas.c b/drivers/firmware/qcom/qcom_pas.c
> new file mode 100644
> index 0000000000000..bc6c42f2b3c61
> --- /dev/null
> +++ b/drivers/firmware/qcom/qcom_pas.c
[ ... ]
> +void qcom_pas_ops_register(struct qcom_pas_ops *ops)
> +{
> + if (!qcom_pas_is_available())
> + /* Paired with smp_load_acquire() in qcom_pas_is_available() */
> + smp_store_release(&ops_ptr, ops);
> + else
> + pr_err("qcom_pas: ops already registered by %s\n",
> + ops_ptr->drv_name);
> +}
> +EXPORT_SYMBOL_GPL(qcom_pas_ops_register);
> +
> +void qcom_pas_ops_unregister(void)
> +{
> + /* Paired with smp_load_acquire() in qcom_pas_is_available() */
> + smp_store_release(&ops_ptr, NULL);
[Severity: High]
Can this lead to state corruption if a second backend driver fails to register
but subsequently unregisters?
Since qcom_pas_ops_register() returns void instead of an error code, if a
second PAS backend (e.g., TEE) probes after the first (e.g., SCM) has
registered, its probe succeeds without owning the registration.
If the second backend is later removed, its remove callback will invoke
qcom_pas_ops_unregister() and unconditionally clear the legitimately registered
ops_ptr. Could this cause a denial of service for remoteproc subsystems
since subsequent PAS operations would fail with -ENODEV?
> +}
> +EXPORT_SYMBOL_GPL(qcom_pas_ops_unregister);
[ ... ]
> diff --git a/drivers/firmware/qcom/qcom_pas_tee.c b/drivers/firmware/qcom/qcom_pas_tee.c
> new file mode 100644
> index 0000000000000..a2ba3af05a502
> --- /dev/null
> +++ b/drivers/firmware/qcom/qcom_pas_tee.c
[ ... ]
> +static void *qcom_pas_tee_get_rsc_table(struct device *dev,
> + struct qcom_pas_context *ctx,
> + void *input_rt, size_t input_rt_size,
> + size_t *output_rt_size)
> +{
[ ... ]
> + if (param[1].u.memref.size) {
> + struct tee_shm *rt_shm __free(shm_free) =
> + tee_shm_alloc_kernel_buf(data->ctx,
> + param[1].u.memref.size);
> + void *rt_shm_va;
> +
> + if (IS_ERR_OR_NULL(rt_shm)) {
> + dev_err(dev, "rt_shm allocation failed\n");
> + rt_shm = NULL;
> + return ERR_PTR(-ENOMEM);
> + }
> +
> + rt_shm_va = tee_shm_get_va(rt_shm, 0);
> + if (IS_ERR(rt_shm_va)) {
> + dev_err(dev, "rt_shm get VA failed\n");
> + return ERR_CAST(rt_shm_va);
> + }
> + memcpy(rt_shm_va, input_rt, input_rt_size);
[Severity: High]
Is there a missing bounds check and NULL check here?
The TEE Trusted Application returns an expected buffer size in
param[1].u.memref.size, which is used to allocate the rt_shm buffer. However,
this memcpy unconditionally copies input_rt_size bytes.
If a compromised or malfunctioning TA returns a size smaller than
input_rt_size, could this result in a heap buffer overflow?
Additionally, if input_rt is NULL and input_rt_size is 0 (which is documented
for firmwares without an embedded resource table), wouldn't this result in
undefined behavior by passing a NULL pointer to memcpy?
> +
> + param[1].u.memref.shm = rt_shm;
> + ret = tee_client_invoke_func(data->ctx, &inv_arg, param);
> + if (ret < 0 || inv_arg.ret != 0) {
> + dev_err(dev, "PAS get RT failed, pas_id: %d, ret: %d, err: 0x%x\n",
> + ctx->pas_id, ret, inv_arg.ret);
> + return ret ? ERR_PTR(ret) : ERR_PTR(-EINVAL);
> + }
> +
> + if (param[1].u.memref.size) {
> + *output_rt_size = param[1].u.memref.size;
> + rt_buf = kmemdup(rt_shm_va, *output_rt_size, GFP_KERNEL);
[Severity: High]
Could this kmemdup read out of bounds?
After the second TEE invocation, the TA can modify param[1].u.memref.size,
which is blindly assigned to *output_rt_size and used in kmemdup.
If the TA increases the size beyond the initially allocated rt_shm buffer size,
wouldn't kmemdup read past the end of the buffer?
> + if (!rt_buf)
> + return ERR_PTR(-ENOMEM);
> + }
> + }
> +
> + return rt_buf;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260626133440.692849-1-sumit.garg@kernel.org?part=7
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
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 [this message]
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=20260627134230.B06C61F00ADB@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.