From: sashiko-bot@kernel.org
To: pankaj.gupta@oss.nxp.com
Cc: devicetree@vger.kernel.org, robh@kernel.org, Frank.Li@kernel.org,
conor+dt@kernel.org, imx@lists.linux.dev
Subject: Re: [PATCH v31 3/7] firmware: imx: add driver for NXP EdgeLock Enclave
Date: Wed, 29 Jul 2026 10:03:57 +0000 [thread overview]
Message-ID: <20260729100357.8F15D1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260729-imx-se-if-v31-3-e59af7adb784@nxp.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] DMA Use-After-Free / Memory Corruption on command timeout
--
--- Patch [3]: [PATCH v31 3/7] firmware: imx: add driver for NXP EdgeLock Enclave ---
commit ae6974582706d865c1232af0bb0e80860d057d5e
Author: Pankaj Gupta <pankaj.gupta@nxp.com>
firmware: imx: add driver for NXP EdgeLock Enclave
Add MU-based communication interface for secure enclave.
NXP hardware IP(s) for secure-enclaves like Edgelock Enclave(ELE), are
embedded in the SoC to support the features like HSM, SHE & V2X, using
message based communication interface.
> Two findings need no code change:
> - DMA free on timeout: -ETIMEDOUT means FW is fenced by fw_busy, so the
> free is safe.
[Severity: High]
Is this description accurate? The fw_busy flag is a software-side atomic variable
that only prevents the kernel from sending subsequent commands. It does nothing
to cancel the in-flight hardware DMA operation. Once the enclave has the physical
address, the kernel cannot safely free the memory until it guarantees the enclave
will no longer write to it.
> diff --git a/drivers/firmware/imx/ele_base_msg.c b/drivers/firmware/imx/ele_base_msg.c
> --- /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);
> +}
[Severity: High]
Does ele_get_info_cleanup() in drivers/firmware/imx/ele_base_msg.c unconditionally
free the DMA buffer back to the allocator even if the firmware is still executing
the command and may write to it?
[ ... ]
> + 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);
> + return ret;
> + }
[Severity: High]
If ele_msg_send_rcv() times out and returns -ETIMEDOUT, won't ele_get_info()
invoke the unsafe free operation while the firmware might still be processing
the request?
> diff --git a/drivers/firmware/imx/ele_common.c b/drivers/firmware/imx/ele_common.c
> --- /dev/null
> +++ b/drivers/firmware/imx/ele_common.c
[ ... ]
> + } else if (header->tag == priv->if_defs->rsp_tag) {
> + bool exception_for_sz_mismatch = check_hdr_exception_for_sz(priv, header);
> + u32 exp_rx_msg_sz = 0;
> +
> + /*
> + * rx_msg and rx_msg_sz are owned by the sender under clbk_rx_lock.
> + * Read both under the lock: drop a late response instead of copying
> + * into freed memory, and avoid a stale size. A late response also
> + * closes the firmware-busy circuit breaker.
> + */
> + se_clbk_hdl = &priv->waiting_rsp_clbk_hdl;
> + spin_lock_irqsave(&se_clbk_hdl->clbk_rx_lock, flags);
> + if (!se_clbk_hdl->rx_msg) {
> + /* Close circuit breaker on spinlock race */
> + atomic_set(&priv->fw_busy, 0);
> + spin_unlock_irqrestore(&se_clbk_hdl->clbk_rx_lock, flags);
> + dev_info(dev, "ELE responded (late), recovery FW available.");
> + return;
> + }
[Severity: High]
When a late response arrives after a timeout, does clearing the software circuit
breaker in se_if_rx_callback() leave the system completely oblivious to the fact
that the hardware just wrote to freed memory?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260729-imx-se-if-v31-0-e59af7adb784@nxp.com?part=3
next prev parent reply other threads:[~2026-07-29 10:03 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-29 10:40 [PATCH v31 0/7] firmware: imx: driver for NXP secure-enclave pankaj.gupta
2026-07-29 10:40 ` [PATCH v31 1/7] Documentation/firmware: add imx/se to other_interfaces pankaj.gupta
2026-07-29 9:55 ` sashiko-bot
2026-07-29 10:40 ` [PATCH v31 2/7] dt-bindings: arm: fsl: add imx-se-fw binding doc pankaj.gupta
2026-07-29 10:40 ` [PATCH v31 3/7] firmware: imx: add driver for NXP EdgeLock Enclave pankaj.gupta
2026-07-29 10:03 ` sashiko-bot [this message]
2026-07-29 17:48 ` Pankaj Gupta (OSS)
2026-07-29 10:40 ` [PATCH v31 4/7] firmware: imx: device context dedicated to priv pankaj.gupta
2026-07-29 10:03 ` sashiko-bot
2026-07-29 17:48 ` Pankaj Gupta (OSS)
2026-07-29 10:40 ` [PATCH v31 5/7] firmware: imx: adds miscdev pankaj.gupta
2026-07-29 10:11 ` sashiko-bot
2026-07-29 17:48 ` Pankaj Gupta (OSS)
2026-07-29 10:40 ` [PATCH v31 6/7] arm64: dts: imx8ulp: add secure enclave node pankaj.gupta
2026-07-29 9:59 ` sashiko-bot
2026-07-29 10:40 ` [PATCH v31 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=20260729100357.8F15D1F000E9@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 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.