From: sashiko-bot@kernel.org
To: "Tao Yu" <tao1.yu@intel.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/gud: validate TV mode names before creating enum property
Date: Wed, 19 Aug 2026 07:38:33 +0000 [thread overview]
Message-ID: <20260819073834.2714F1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260819072835.4074130-1-tao1.yu@intel.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] A malicious or non-compliant USB device can cause a kernel NULL pointer dereference in `drm_object_attach_property` by ordering TV properties such that `GUD_PROPERTY_TV_MODE` is returned after other TV properties.
--
--- Patch [1]: [PATCH] drm/gud: validate TV mode names before creating enum property ---
commit db9280e75e6e04eacd06127a0240a5d76af230f9
Author: Tao Yu <tao1.yu@intel.com>
drm/gud: validate TV mode names before creating enum property
The GUD protocol returns TV mode names as fixed-size entries that require
NUL-termination. This commit validates that each returned TV mode name
contains a NUL terminator within its fixed-size slot before passing it to
the DRM property code, preventing an out-of-bounds read in strlen().
> diff --git a/drivers/gpu/drm/gud/gud_connector.c b/drivers/gpu/drm/gud/gud_connector.c
> index ea0cca58b7c89..8141c3a1e30ad 100644
> --- a/drivers/gpu/drm/gud/gud_connector.c
> +++ b/drivers/gpu/drm/gud/gud_connector.c
> @@ -396,8 +396,16 @@ static int gud_connector_add_tv_mode(struct gud_device *gdrm, struct drm_connect
> }
>
> num_modes = ret / GUD_CONNECTOR_TV_MODE_NAME_LEN;
> - for (i = 0; i < num_modes; i++)
> - modes[i] = &buf[i * GUD_CONNECTOR_TV_MODE_NAME_LEN];
> + for (i = 0; i < num_modes; i++) {
> + char *mode = &buf[i * GUD_CONNECTOR_TV_MODE_NAME_LEN];
> +
> + if (!memchr(mode, '\0', GUD_CONNECTOR_TV_MODE_NAME_LEN)) {
> + ret = -EIO;
> + goto free;
> + }
> +
> + modes[i] = mode;
> + }
>
> ret = drm_mode_create_tv_properties_legacy(connector->dev, num_modes, modes);
[Severity: High]
This is a pre-existing issue, but can a malicious or non-compliant USB device
cause a kernel NULL pointer dereference in drm_object_attach_property() by
ordering TV properties such that GUD_PROPERTY_TV_MODE is returned after other
TV properties?
If a USB device returns GUD_PROPERTY_TV_HUE (or similar TV properties) before
GUD_PROPERTY_TV_MODE, gud_connector_add_properties() processes it and calls
drm_mode_create_tv_properties_legacy(drm, 0, NULL). This initializes
dev->mode_config.tv_select_subconnector_property but leaves
legacy_tv_mode_property as NULL since num_modes is 0.
Later, when GUD_PROPERTY_TV_MODE is processed, gud_connector_add_tv_mode()
calls drm_mode_create_tv_properties_legacy() here with actual modes. Because
tv_select_subconnector_property is already set, this second call hits an
early return in drm_mode_create_tv_properties_legacy():
drivers/gpu/drm/drm_connector.c:drm_mode_create_tv_properties_legacy() {
if (dev->mode_config.tv_select_subconnector_property)
return 0;
...
This immediately succeeds without creating legacy_tv_mode_property.
gud_connector_property_lookup() is then called for GUD_PROPERTY_TV_MODE and
returns the uninitialized config->legacy_tv_mode_property, which is NULL.
In gud_connector_add_properties():
property = gud_connector_property_lookup(connector, prop);
if (drm_WARN_ON(drm, IS_ERR(property)))
continue;
The IS_ERR(property) check fails to catch NULL, and
drm_object_attach_property() is called with the NULL property,
unconditionally dereferencing property->dev.
> free:
> kfree(buf);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260819072835.4074130-1-tao1.yu@intel.com?part=1
next prev parent reply other threads:[~2026-08-19 7:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-19 7:28 [PATCH] drm/gud: validate TV mode names before creating enum property Tao Yu
2026-08-19 7:38 ` sashiko-bot [this message]
2026-08-19 8:14 ` Tao Yu
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=20260819073834.2714F1F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tao1.yu@intel.com \
/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.