From: sashiko-bot@kernel.org
To: "Luo Liu" <Luo.Liu@cixtech.com>, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 4/4] drm/bridge: tda998x: fix DRM_BRIDGE_ATTACH_NO_CONNECTOR support
Date: Tue, 24 Nov 2026 10:03:41 +0000 [thread overview]
Message-ID: <sashiko-outbox-230904@kernel.org> (raw)
In-Reply-To: <20261124094119.3220267-5-Luo.Liu@cixtech.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] drm/bridge: tda998x: UAF on cached bridge_connector in
tda998x_audio_get_eld()
- [Medium] drm/bridge: tda998x: tda998x_detect_work() drops HPD before
detect/edid_read
- [Medium] drm/bridge: tda998x: unlocked connector->eld read in
tda998x_audio_get_eld()
--
commit 99202632262d8379c5cf8d903d42f1dd5e5ce3eb
Author: Luo Liu <Luo.Liu@cixtech.com>
drm/bridge: tda998x: fix DRM_BRIDGE_ATTACH_NO_CONNECTOR support
This commit caches the drm_connector pointer passed to the bridge detect and
EDID read callbacks so mode setting, infoframe generation, ELD retrieval, and
hotplug notifications use the external bridge connector when attached with
DRM_BRIDGE_ATTACH_NO_CONNECTOR, and enables interlaced mode support on the
bridge.
> diff --git a/drivers/gpu/drm/bridge/tda998x_drv.c b/drivers/gpu/drm/bridge/tda998x_drv.c
> index 0b966c9844e70..40379d74a53ac 100644
> --- a/drivers/gpu/drm/bridge/tda998x_drv.c
> +++ b/drivers/gpu/drm/bridge/tda998x_drv.c
[ ... ]
> @@ -769,6 +783,14 @@ static int tda998x_edid_delay_wait(struct tda998x_priv *priv)
> return wait_event_killable(priv->edid_delay_waitq, !priv->edid_delay_active);
> }
>
> +static enum drm_connector_status tda998x_conn_detect(struct tda998x_priv *priv)
> +{
> + u8 val = cec_read(priv, REG_CEC_RXSHPDLEV);
> +
> + return (val & CEC_RXSHPDLEV_HPD) ? connector_status_connected :
> + connector_status_disconnected;
> +}
> +
> /*
> * We need to run the KMS hotplug event helper outside of our threaded
> * interrupt routine as this can call back into our get_modes method,
> @@ -778,10 +800,11 @@ static void tda998x_detect_work(struct work_struct *work)
> {
> struct tda998x_priv *priv =
> container_of(work, struct tda998x_priv, detect_work);
> - struct drm_device *dev = priv->connector.dev;
>
> - if (dev)
> - drm_kms_helper_hotplug_event(dev);
> + if (priv->bridge_connector)
> + drm_bridge_hpd_notify(&priv->bridge, tda998x_conn_detect(priv));
> + else if (priv->connector.dev)
> + drm_kms_helper_hotplug_event(priv->connector.dev);
> }
[Severity: Medium]
Does checking priv->bridge_connector here drop HPD events that arrive before
tda998x_bridge_detect() or tda998x_bridge_edid_read() has been called?
When attached with DRM_BRIDGE_ATTACH_NO_CONNECTOR, priv->connector.dev is
NULL and priv->bridge_connector is only populated inside .detect() and
.edid_read(). drm_bridge_connector_init() and drm_kms_helper_poll_init() ->
drm_bridge_connector_enable_hpd() enable HPD without calling either callback
and without starting periodic polling when DRM_BRIDGE_OP_HPD is set. If an
HPD interrupt fires before any caller probes the connector (or if a
downstream bridge in the chain handles DRM_BRIDGE_OP_DETECT and
DRM_BRIDGE_OP_EDID), both pointers are NULL and the notification is lost,
even though drm_bridge_hpd_notify() only needs &priv->bridge.
[ ... ]
> @@ -1152,10 +1176,10 @@ static int tda998x_audio_get_eld(struct device *dev, void *data,
> uint8_t *buf, size_t len)
> {
> struct tda998x_priv *priv = dev_get_drvdata(dev);
> + struct drm_connector *connector = tda998x_get_connector(priv);
>
> mutex_lock(&priv->audio_mutex);
> - memcpy(buf, priv->connector.eld,
> - min(sizeof(priv->connector.eld), len));
> + memcpy(buf, connector->eld, min(sizeof(connector->eld), len));
> mutex_unlock(&priv->audio_mutex);
>
> return 0;
> }
[Severity: Medium]
Should tda998x_audio_get_eld() hold connector->eld_mutex while copying
connector->eld?
drm_edid_connector_update() zeroes and populates connector->eld under
connector->eld_mutex without holding priv->audio_mutex, so a concurrent
ALSA ELD read can copy a partially updated or transiently zeroed ELD buffer.
[ ... ]
> @@ -1390,6 +1406,8 @@ static void tda998x_bridge_detach(struct drm_bridge *bridge)
> {
> struct tda998x_priv *priv = bridge_to_tda998x_priv(bridge);
>
> + priv->bridge_connector = NULL;
> +
> if (priv->connector.dev)
> drm_connector_cleanup(&priv->connector);
> }
[ ... ]
> @@ -1701,6 +1720,9 @@ tda998x_bridge_edid_read(struct drm_bridge *bridge,
> const struct drm_edid *drm_edid;
> const struct edid *edid;
>
> + if (connector)
> + priv->bridge_connector = connector;
> +
> drm_edid = tda998x_edid_read(priv, connector);
> if (!drm_edid) {
> dev_dbg(&priv->hdmi->dev, "failed to get edid\n");
> @@ -1729,6 +1751,9 @@ tda998x_bridge_detect(struct drm_bridge *bridge,
> {
> struct tda998x_priv *priv = bridge_to_tda998x_priv(bridge);
>
> + if (connector)
> + priv->bridge_connector = connector;
> +
> return tda998x_conn_detect(priv);
> }
[Severity: High]
Can caching the raw connector pointer in priv->bridge_connector cause a
use-after-free in tda998x_audio_get_eld()?
include/drm/drm_bridge.h forbids storing the connector parameter passed to
.edid_read() for future use. Display controller drivers such as tilcdc
register their encoder with drmm before calling drm_bridge_connector_init():
drivers/gpu/drm/tilcdc/tilcdc_encoder.c:tilcdc_encoder_create() {
...
encoder = drmm_simple_encoder_alloc(ddev, struct tilcdc_encoder,
base, DRM_MODE_ENCODER_NONE);
...
return tilcdc_attach_bridge(ddev, bridge);
}
Because drmm release actions run in reverse registration order while
priv->audio_pdev remains registered until tda998x_remove(), DRM teardown
frees the drm_bridge_connector before tda998x_bridge_detach() clears
priv->bridge_connector (and neither access is serialized by
priv->audio_mutex):
CPU0 CPU1
drm_managed_release()
drmm_connector_init_release()
drmm_kfree() /* frees connector */
tda998x_audio_get_eld()
connector = tda998x_get_connector()
memcpy(buf, connector->eld, ...)
<-- use-after-free
drmm_encoder_alloc_release()
drm_encoder_cleanup()
drm_bridge_detach()
tda998x_bridge_detach()
priv->bridge_connector = NULL;
In addition, if a downstream bridge in the chain handles
DRM_BRIDGE_OP_DETECT and DRM_BRIDGE_OP_EDID, drm_bridge_connector never
calls tda998x_bridge_detect() or tda998x_bridge_edid_read(), leaving
priv->bridge_connector NULL during tda998x_bridge_mode_set().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124094119.3220267-1-Luo.Liu@cixtech.com?part=4
next prev parent reply other threads:[~2026-11-24 10:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 9:41 [PATCH v3 0/4] drm/komeda: Use the bridge connector Luo Liu
2026-11-24 9:41 ` [PATCH v3 1/4] " Luo Liu
2026-11-24 9:41 ` [PATCH v3 2/4] drm/komeda: Use drmm_mode_config_init() Luo Liu
2026-11-24 9:41 ` [PATCH v3 3/4] drm/komeda: Free the IRQ before clearing dev_private Luo Liu
2026-11-24 9:41 ` [PATCH v3 4/4] drm/bridge: tda998x: fix DRM_BRIDGE_ATTACH_NO_CONNECTOR support Luo Liu
2026-11-24 10:03 ` sashiko-bot [this message]
2026-11-27 17:05 ` [PATCH v3 0/4] drm/komeda: Use the bridge connector Luca Ceresoli
2026-11-30 2:31 ` 回复: " Luo Liu
2026-11-30 2:31 ` Luo Liu
-- strict thread matches above, loose matches on Subject: below --
2026-11-24 9:39 Luo Liu
2026-11-24 9:39 ` [PATCH v3 4/4] drm/bridge: tda998x: fix DRM_BRIDGE_ATTACH_NO_CONNECTOR support Luo Liu
2026-11-24 10:02 ` sashiko-bot
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=sashiko-outbox-230904@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Luo.Liu@cixtech.com \
--cc=dri-devel@lists.freedesktop.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.