firmware: imx: secure-enclave: fix list UAF in init_device_context()
PATCH 1/1 firmware: imx: secure-enclave: fix list UAF in init_device_context()
init_device_context() added a new device context to priv->dev_ctx_list before calling init_se_shared_mem(). If initialization failed, the device context was freed without being removed from the list, leaving behind a dangling list entry.
Move the list insertion until after all fallible initialization has completed successfully.
--- drivers/firmware/imx/se_ctrl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/firmware/imx/se_ctrl.c +3 -3
@@ -481,9 +481,6 @@ static int init_device_context(struct se_if_priv *priv, int ch_id, dev_ctx->priv = priv; *new_dev_ctx = dev_ctx; -list_add_tail (&dev_ctx->link, &priv->dev_ctx_list); - priv->active_devctx_count++; - ret =init_se_shared_mem (dev_ctx);if (ret <0 ) {kfree (dev_ctx->devname);
@@ -491,6 +488,9 @@ static int init_device_context(struct se_if_priv *priv, int ch_id, *new_dev_ctx =NULL ; } +list_add_tail (&dev_ctx->link, &priv->dev_ctx_list); + priv->active_devctx_count++; +return ret; }
Signature · 1 line
2.43.0
Quoted 9 lines · Pankaj Gupta
init_device_context()added a new device context topriv->dev_ctx_listbefore callinginit_se_shared_mem(). If initialization failed, the device context was freed without being removed from the list, leaving behind a dangling list entry.Move the list insertion until after all fallible initialization has completed successfully.
[...]
Applied, thanks!
[1/1] firmware: imx: secure-enclave: fix list UAF in init_device_context()
commit: 66f3c3f91c48238dd13543cd428879b9184c80f4
Best regards,
Signature · 1 line
Frank Li <[email protected]>