Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] drm/bridge: ti-sn65dsi86: UAF on pdata->next_bridge in
  sn65dsi86_get_next_bridge()
--

commit 79f96bd174206efa5c1019cb2a4980bed689b63c
Author: Luca Ceresoli <[email protected]>

drm/bridge: ti-sn65dsi86: implement .get_next_bridge

This commit implements the .get_next_bridge callback and sets
DRM_BRIDGE_OP_GET_NEXT_BRIDGE to expose the downstream bridge in the
ti-sn65dsi86 driver.

> diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c 
> b/drivers/gpu/drm/bridge/ti-sn65dsi86.c
> index 38318113a534f..6dadcd7eb8d18 100644
> --- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c
> +++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c
> @@ -743,6 +743,13 @@ static int ti_sn_attach_host(struct auxiliary_device 
> *adev, struct ti_sn65dsi86
>       return devm_mipi_dsi_attach(&adev->dev, dsi);
>  }
>  
> +static struct drm_bridge *sn65dsi86_get_next_bridge(struct drm_bridge 
> *bridge)
> +{
> +     struct ti_sn65dsi86 *pdata = bridge_to_ti_sn65dsi86(bridge);
> +
> +     return pdata->next_bridge ? drm_bridge_get(pdata->next_bridge) : 
> ERR_PTR(-ENODEV);
> +}

[Severity: High]
Can sn65dsi86_get_next_bridge() pass a dangling or ERR_PTR pointer to
drm_bridge_get()?

ti_sn_bridge_probe() obtains pdata->next_bridge with
devm_drm_of_get_bridge(&adev->dev, np, 1, 0).  For a non-panel downstream
bridge (such as a DisplayPort connector bridge), devm_drm_of_get_bridge()
does not hold a reference to the returned bridge, so pdata->next_bridge
becomes a dangling pointer if the downstream bridge is removed and freed.

Even for a panel bridge, its devres release is bound to the child
auxiliary device (&adev->dev), whereas pdata->bridge lives on the parent
I2C device and neither ti_sn_bridge_remove() nor the probe error path
clears pdata->next_bridge.  In addition, ti_sn_bridge_probe() stores the
result of devm_drm_of_get_bridge() directly into pdata->next_bridge before
checking IS_ERR(), so a failed re-probe leaves an ERR_PTR in
pdata->next_bridge that passes the non-NULL check here and is dereferenced
by drm_bridge_get().

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=24

Reply via email to