From: sashiko-bot@kernel.org
To: pankaj.gupta@oss.nxp.com
Cc: Frank.Li@kernel.org, conor+dt@kernel.org, imx@lists.linux.dev,
devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH v41 4/7] firmware: imx: device context dedicated to priv
Date: Mon, 24 Aug 2026 09:17:43 +0000 [thread overview]
Message-ID: <20260824091743.D9E5B1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260824-imx-se-if-v41-4-29cf129e4d86@nxp.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Pre-existing Use-After-Free of `priv->se_if_cmd_lock` due to incorrect devres action ordering.
--
--- Patch [4]: [PATCH v41 4/7] firmware: imx: device context dedicated to priv ---
commit d02e4a5df59f7ab91519903b9c6543123c1e4afc
Author: Pankaj Gupta <pankaj.gupta@nxp.com>
firmware: imx: device context dedicated to priv
Add priv_dev_ctx to prepare enabling misc-device context based send-receive
path, to communicate with FW.
> diff --git a/drivers/firmware/imx/se_ctrl.c b/drivers/firmware/imx/se_ctrl.c
> --- a/drivers/firmware/imx/se_ctrl.c
> +++ b/drivers/firmware/imx/se_ctrl.c
[ ... ]
> @@ -437,6 +465,11 @@ static int se_if_probe(struct platform_device *pdev)
> load_fw->imem_mgmt = true;
> }
>
> + ret = init_misc_device_context(priv, 0, &priv->priv_dev_ctx);
> + if (ret)
> + return dev_err_probe(dev, ret,
> + "Failed to create device contexts.\n");
[Severity: High]
This is a pre-existing issue, but does adding this new failure path make it
easier to trigger a use-after-free during devres unwind?
Looking at se_if_probe(), earlier in the function devm_mutex_init() is called
for priv->se_if_cmd_lock:
se_if_probe()
ret = devm_mutex_init(dev, &priv->se_if_cmd_lock);
...
ret = devm_add_action_or_reset(dev, se_if_probe_cleanup, pdev);
Because devres actions are executed in reverse order of addition, if this new
init_misc_device_context() fails, the unwind will first call
se_if_probe_cleanup(), which frees priv:
se_if_probe_cleanup()
...
kfree(priv);
Then devres will run the mutex destroy action for priv->se_if_cmd_lock,
resulting in a use-after-free on the freed priv structure when
CONFIG_DEBUG_MUTEXES is enabled.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260824-imx-se-if-v41-0-29cf129e4d86@nxp.com?part=4
next prev parent reply other threads:[~2026-08-24 9:17 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-24 14:33 [PATCH v41 0/7] firmware: imx: driver for NXP secure-enclave pankaj.gupta
2026-08-24 14:33 ` [PATCH v41 1/7] Documentation/firmware: add imx/se to other_interfaces pankaj.gupta
2026-08-24 9:09 ` sashiko-bot
2026-08-24 14:33 ` [PATCH v41 2/7] dt-bindings: arm: fsl: add imx-se-fw binding doc pankaj.gupta
2026-08-24 14:33 ` [PATCH v41 3/7] firmware: imx: add driver for NXP EdgeLock Enclave pankaj.gupta
2026-08-24 9:13 ` sashiko-bot
2026-08-24 14:33 ` [PATCH v41 4/7] firmware: imx: device context dedicated to priv pankaj.gupta
2026-08-24 9:17 ` sashiko-bot [this message]
2026-08-24 14:33 ` [PATCH v41 5/7] firmware: imx: adds miscdev pankaj.gupta
2026-08-24 9:19 ` sashiko-bot
2026-08-24 14:33 ` [PATCH v41 6/7] arm64: dts: imx8ulp: add secure enclave node pankaj.gupta
2026-08-24 14:33 ` [PATCH v41 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=20260824091743.D9E5B1F000E9@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.