From: sashiko-bot@kernel.org
To: pankaj.gupta@oss.nxp.com
Cc: imx@lists.linux.dev, conor+dt@kernel.org,
devicetree@vger.kernel.org, Frank.Li@kernel.org, robh@kernel.org
Subject: Re: [PATCH v34 3/7] firmware: imx: add driver for NXP EdgeLock Enclave
Date: Wed, 05 Aug 2026 16:17:58 +0000 [thread overview]
Message-ID: <20260805161759.08C341F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260805-imx-se-if-v34-3-7e4713d14e0a@nxp.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Critical] The DMA buffer passed to the enclave firmware is freed unconditionally on timeout, creating a window where delayed firmware operations will corrupt memory.
- [Medium] The core messaging function `ele_msg_send_rcv` incorrectly returns `-ERESTARTSYS` when a firmware command completes successfully, but a signal was received during the wait. This causes non-idempotent operations to be incorrectly reported as interrupted and potentially re-executed.
--
--- Patch [3]: [PATCH v34 3/7] firmware: imx: add driver for NXP EdgeLock Enclave ---
commit 33c1a4b0c7dcc5a0ad9f6bb5fbdd591b9371ef2d
Author: Pankaj Gupta <pankaj.gupta@nxp.com>
Subject: firmware: imx: add driver for NXP EdgeLock Enclave
Add MU-based communication interface for secure enclave. The secure enclave
FW communicates with Linux over single or multiple dedicated messaging
unit(MU) based interface(s). Exists on i.MX SoC(s) like i.MX8ULP, i.MX93,
i.MX95 etc.
Closes: https://sashiko.dev/#/patchset/20260121-imx-se-if-v32-0-c5222df51cc2@nxp.com?part=3
> diff --git a/drivers/firmware/imx/ele_base_msg.c b/drivers/firmware/imx/ele_base_msg.c
> index 0000000000000..724f6e913ce79
> --- /dev/null
> +++ b/drivers/firmware/imx/ele_base_msg.c
[ ... ]
> +static void 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);
> +}
> +
> +int ele_get_info(struct se_if_priv *priv, struct ele_dev_info *s_info)
> +{
[ ... ]
> + ret = ele_msg_send_rcv(priv, 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);
[Severity: Critical]
If ele_msg_send_rcv() times out and returns -ETIMEDOUT, does this unconditionally
free the DMA buffer while the firmware might still be active?
If the firmware is merely slow and responds after the timeout, it could write
up to 160 bytes into this physical memory after it has been returned to the
page allocator or gen_pool, potentially causing memory corruption.
Should we avoid freeing this buffer if the firmware transaction has not been safely
aborted?
> + return ret;
> + }
> diff --git a/drivers/firmware/imx/ele_common.c b/drivers/firmware/imx/ele_common.c
> index 0000000000000..bc08ea2dcd87d
> --- /dev/null
> +++ b/drivers/firmware/imx/ele_common.c
[ ... ]
> +int ele_msg_send_rcv(struct se_if_priv *priv, void *tx_msg, int tx_msg_sz,
> + void *rx_msg, int exp_rx_msg_sz)
> +{
[ ... ]
> + if (priv->waiting_rsp_clbk_hdl.signal_rcvd) {
> + /*
> + * Signal was deferred until the FW/kernel protocol resynchronized.
> + * On success report -ERESTARTSYS for the interrupted wait; the
> + * command is not re-sent. Keep real errors like -ETIMEDOUT.
> + */
> + if (err > 0)
> + err = -ERESTARTSYS;
[Severity: Medium]
If a signal is received but the firmware successfully completes the command
(err > 0), replacing the result with -ERESTARTSYS discards the hardware
response data.
Could this cause issues if the operation is exposed to userspace later? The
VFS would restart the syscall and re-execute the firmware operation, which
might not be idempotent.
Is it intentional to discard a successful response here?
> + priv->waiting_rsp_clbk_hdl.signal_rcvd = false;
> + dev_dbg(priv->dev, "Err[0x%x]:Interrupted by signal.", err);
> + }
> +
> + ele_msg_send_rcv_cleanup(priv);
> +
> + return err;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260805-imx-se-if-v34-0-7e4713d14e0a@nxp.com?part=3
next prev parent reply other threads:[~2026-08-05 16:17 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 [this message]
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
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=20260805161759.08C341F000E9@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