From: sashiko-bot@kernel.org
To: pankaj.gupta@oss.nxp.com
Cc: devicetree@vger.kernel.org, imx@lists.linux.dev, robh@kernel.org,
conor+dt@kernel.org, Frank.Li@kernel.org
Subject: Re: [PATCH v34 4/7] firmware: imx: device context dedicated to priv
Date: Wed, 05 Aug 2026 16:22:55 +0000 [thread overview]
Message-ID: <20260805162256.59BFC1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260805-imx-se-if-v34-4-7e4713d14e0a@nxp.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] In `ele_get_info()`, a physical DMA buffer (`get_info_data`) is allocated and mapped for the firmware to write its response. If the firmware takes too long to respond, `ele_msg_send_rcv()` times out and returns `-ETIMEDOUT`, setting the firmware state to busy. However, on this error path, `ele_get_info()` calls `ele_get_info_cleanup()`, which unconditionally frees the DMA buffer (via `dma_free_coherent()` or `gen_pool_free()`). Because the firmware may still be processing the command, it could eventually finish and write its response to the now-freed physical address, leading to a DMA Use-After-Free that corrupts memory. The buffer must be quarantined (leaked) if the firmware is unresponsive.
--
--- Patch [4]: [PATCH v34 4/7] firmware: imx: device context dedicated to priv ---
commit c0e62ad2fda653db9c2508807fbec3d62a1f2511
Author: Pankaj Gupta <pankaj.gupta@nxp.com>
firmware: imx: device context dedicated to priv
This patch adds a private device context to se_if_priv to prepare for
misc-device context-based send-receive paths. It updates several firmware
message passing functions to take the new priv_dev_ctx instead of the
top-level priv structure.
> diff --git a/drivers/firmware/imx/ele_base_msg.c b/drivers/firmware/imx/ele_base_msg.c
> --- a/drivers/firmware/imx/ele_base_msg.c
> +++ b/drivers/firmware/imx/ele_base_msg.c
> @@ -71,8 +71,9 @@ int ele_get_info(struct se_if_priv *priv, struct ele_dev_info *s_info)
> tx_msg->data[0] = upper_32_bits(get_info_addr);
> tx_msg->data[1] = lower_32_bits(get_info_addr);
> tx_msg->data[2] = sizeof(*s_info);
> - ret = ele_msg_send_rcv(priv, tx_msg, ELE_GET_INFO_REQ_MSG_SZ, rx_msg,
> - ELE_GET_INFO_RSP_MSG_SZ);
> +
> + ret = ele_msg_send_rcv(priv->priv_dev_ctx, tx_msg, ELE_GET_INFO_REQ_MSG_SZ,
> + rx_msg, ELE_GET_INFO_RSP_MSG_SZ);
> if (ret < 0) {
> ele_get_info_cleanup(priv, get_info_data, get_info_addr, get_info_len);
> return ret;
[Severity: High]
If ele_msg_send_rcv() times out and returns -ETIMEDOUT, the firmware state is
marked as busy, but this error path calls ele_get_info_cleanup() which
unconditionally frees the DMA buffer get_info_data:
ele_get_info_cleanup(struct se_if_priv *priv, u32 *buf, dma_addr_t d_addr,
size_t size)
{
if (priv->mem_pool)
gen_pool_free(priv->mem_pool, (unsigned long)buf, size);
else
dma_free_coherent(priv->dev, size, buf, d_addr);
}
If the firmware is just slow and later completes the command, will it write
its response into this now-freed physical address, causing a DMA
use-after-free and memory corruption?
Should this buffer be quarantined instead of freed when the firmware is
unresponsive?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260805-imx-se-if-v34-0-7e4713d14e0a@nxp.com?part=4
next prev parent reply other threads:[~2026-08-05 16:22 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-05 16:48 [PATCH v34 0/7] firmware: imx: driver for NXP secure-enclave pankaj.gupta
2026-08-05 16:48 ` [PATCH v34 1/7] Documentation/firmware: add imx/se to other_interfaces pankaj.gupta
2026-08-05 16:04 ` sashiko-bot
2026-08-05 16:48 ` [PATCH v34 2/7] dt-bindings: arm: fsl: add imx-se-fw binding doc pankaj.gupta
2026-08-05 16:48 ` [PATCH v34 3/7] firmware: imx: add driver for NXP EdgeLock Enclave pankaj.gupta
2026-08-05 16:17 ` sashiko-bot
2026-08-05 16:48 ` [PATCH v34 4/7] firmware: imx: device context dedicated to priv pankaj.gupta
2026-08-05 16:22 ` sashiko-bot [this message]
2026-08-05 16:48 ` [PATCH v34 5/7] firmware: imx: adds miscdev pankaj.gupta
2026-08-05 16:30 ` sashiko-bot
2026-08-05 16:48 ` [PATCH v34 6/7] arm64: dts: imx8ulp: add secure enclave node pankaj.gupta
2026-08-05 16:31 ` sashiko-bot
2026-08-05 16:48 ` [PATCH v34 7/7] arm64: dts: imx8ulp: add reserved memory for EdgeLock Enclave pankaj.gupta
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=20260805162256.59BFC1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=imx@lists.linux.dev \
--cc=pankaj.gupta@oss.nxp.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox