> -----邮件原件-----
> 发件人: [email protected] <[email protected]>
> 发送时间: 2026年12月4日 20:02
> 收件人: Luo Liu <[email protected]>
> 抄送: [email protected]; [email protected];
> [email protected]; [email protected]
> 主题: Re: [PATCH v10 5/5] drm/cix: add the Sky1 DisplayPort platform glue
>
> EXTERNAL EMAIL
>
> Thank you for your contribution! Sashiko AI review found 3 potential issues to
> consider:
> - [Medium] drm/bridge: trilinear: unlocked device_link_remove() UAF on
>   dp->dev
> - [Medium] drm/bridge: trilinear: missing dp->released check in
>   dptx_bridge_mode_set()
> - [Low] drm/cix: bridge glue placed in top-level drm/cix/ instead of
>   drm/bridge/
> --
>
> commit 1e4145188b36c3532088673583ce49d4b100b5b9
> Author: Luo Liu <[email protected]>
>
> drm/cix: add the Sky1 DisplayPort platform glue
>
> This commit adds the Cix Sky1 platform glue driver that maps the RCSU video
> adapter registers and binds the shared Trilinear DisplayPort bridge driver.
>
> [ ... ]
>
> > diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index
> > 61111d50b1c65..a1808db8b9c8a 100644
> > --- a/drivers/gpu/drm/Kconfig
> > +++ b/drivers/gpu/drm/Kconfig
> > @@ -311,6 +311,7 @@ source "drivers/gpu/drm/aspeed/Kconfig"
> >  source "drivers/gpu/drm/ast/Kconfig"
> >  source "drivers/gpu/drm/atmel-hlcdc/Kconfig"
> >  source "drivers/gpu/drm/bridge/Kconfig"
> > +source "drivers/gpu/drm/cix/Kconfig"
> >  source "drivers/gpu/drm/etnaviv/Kconfig"
> >  source "drivers/gpu/drm/exynos/Kconfig"
> >  source "drivers/gpu/drm/fsl-dcu/Kconfig"
> > diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index
> > 2c6bc093a923a..6ed7456bb993a 100644
> > --- a/drivers/gpu/drm/Makefile
> > +++ b/drivers/gpu/drm/Makefile
> > @@ -169,6 +169,7 @@ obj-y                     += tests/
> >  obj-$(CONFIG_DRM_MIPI_DBI) += drm_mipi_dbi.o
> >  obj-$(CONFIG_DRM_MIPI_DSI) += drm_mipi_dsi.o
> >  obj-y                        += arm/
> > +obj-y                        += cix/
> >  obj-y                        += clients/
> >  obj-y                        += display/
> >  obj-$(CONFIG_DRM_TTM)        += ttm/
>
> [Severity: Low]
> Should this bridge platform glue live under drivers/gpu/drm/bridge/ (or
> drivers/gpu/drm/bridge/trilinear/) rather than a new top-level
> drivers/gpu/drm/cix/ directory?
>
> drivers/gpu/drm/cix/ contains no drm_driver, only a single 181-line wrapper 
> for
> the Trilinear bridge driver.  Putting it at the top level exposes DRM_CIX_DP
> outside the Display Interface Bridges menu and adds four extra 
> Kconfig/Makefile
> files, whereas comparable SoC bridge wrappers such as
> drivers/gpu/drm/bridge/th1520-dw-hdmi.c and
> drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-j721e.c sit under
> drivers/gpu/drm/bridge/.


The CIX directory is intentional. It is not a wrapper around the
Trilinear bridge: it implements the CIX-specific side, namely the RCSU
video-adapter format and pixel-per-cycle programming, and it supplies
the per-compatible platform data (USB-C versus native DP, out-of-band
HPD, link limits) that the shared code in drivers/gpu/drm/bridge/
trilinear/ must not know about.

That code will keep growing as more CIX SoCs and output variants (eDP,
HDMI through a converter) are supported, each with its own register
layout and quirks. Keeping it in a private vendor directory keeps the
Trilinear code SoC-agnostic and gives the CIX code a stable home instead
of moving it later. If the Kconfig menu placement is the concern rather
than the directory, I can source the CIX Kconfig from the bridge menu.


>
> [ ... ]
>
> > diff --git a/drivers/gpu/drm/cix/dptx/cix_dptx.c
> > b/drivers/gpu/drm/cix/dptx/cix_dptx.c
> > new file mode 100644
> > index 0000000000000..e25b3b365d7b8
> > --- /dev/null
> > +++ b/drivers/gpu/drm/cix/dptx/cix_dptx.c
>
> [ ... ]
>
> > +static void cix_dptx_remove(struct platform_device *pdev) {
> > +     trilinear_dptx_remove(platform_get_drvdata(pdev));
> > +}
>
> [Severity: Medium]
> Can cix_dptx_remove() allow dp->dev to be freed while dptx_bridge_detach() is
> still about to pass it to device_link_remove()?
>
> CPU0 (bridge detach)              CPU1 (platform device delete)
> dptx_bridge_detach()
>   lock(&dp->lock)
>   consumer = dp->link_consumer
>   dp->link_consumer = NULL
>   unlock(&dp->lock)
>                                   device_unregister(dp->dev)
>                                     device_del(dp->dev)
>                                       cix_dptx_remove()
>                                         dptx_deinit()
>                                           lock(&dp->lock)
>                                           /* link_consumer == NULL
> */
>                                           unlock(&dp->lock)
>                                       device_links_purge(dp->dev)
>                                     put_device(dp->dev) /* freed */
>   device_link_remove(consumer,
>                      dp->dev)  <-- use-after-free
>
> trilinear_dptx_probe() stores dp->dev without taking a device reference, and
> dptx_bridge_attach() adds a DL_FLAG_STATELESS link, so removing the supplier
> device does not unbind the consumer first.  Because dptx_bridge_detach()
> clears dp->link_consumer and drops dp->lock before calling
> device_link_remove(), dptx_deinit() returns immediately and device_del()
> purges the link and frees dp->dev before device_link_remove() walks
> supplier->links.consumers.
>
> Calling device_link_remove() while still holding dp->lock in
> dptx_bridge_detach() (matching the dp->lock -> device_links_write_lock
> ordering already used in dptx_bridge_attach()) would serialize link removal 
> with
> dptx_deinit().
>
> [Severity: Medium]
> Can dptx_bridge_mode_set() dereference a freed dp->dev if cix_dptx_remove()
> runs between dp->ops->detect() and reacquiring dp->lock?
>
> CPU0 (modeset)                    CPU1 (platform device delete)
> dptx_bridge_mode_set()
>   dp->ops->detect(dp)
>     /* locks, checks released,
>        unlocks */
>                                   device_unregister(dp->dev)
>                                     cix_dptx_remove()
>                                       dptx_deinit()
>                                         dp->released = true
>                                         device_link_remove(...)
>                                     put_device(dp->dev) /* freed */
>   guard(mutex)(&dp->lock)
>   /* no dp->released check */
>   dev_dbg(dp->dev, ...)  <-- use-after-free
>
> dptx_bridge_mode_set() releases dp->lock when dp->ops->detect() returns and
> does not re-check dp->released after reacquiring it.  Because dp->bridge keeps
> dp alive after dp->dev is freed, dptx_bridge_mode_set() mutates state on a
> released bridge and dereferences freed dp->dev in dev_dbg() when dynamic
> debug is enabled.
>
> Checking dp->released and returning -ENODEV immediately after acquiring
> dp->lock in dptx_bridge_mode_set() would close this window.
>
> --
> Sashiko AI
> review · https://sashiko.dev/#/patchset/20261204114332.280808-1-Luo.Liu@c
> ixtech.com?part=5


本邮件及其附件包含CIX公司的保密信息,受法律保护,仅供本邮件指定的收件人查阅。严禁任何未经授权的使用、传播、分发或复制本邮件及其任何内容。此限制适用于指定收件人以外的所有人员,包括未经明确授权处理此类信息的CIX公司员工或代理人。若您误收本邮件,请立即通知发件人,并永久删除邮件及所有附件。互联网传输无法保证及时性、安全性、完整性和无病毒性,CIX公司对任何传输错误或遗漏概不承担责任。

Reply via email to