diff options
| author | Tao Yu <tao1.yu@intel.com> | 2026-08-19 15:28:35 +0800 |
|---|---|---|
| committer | Ruben Wauters <rubenru09@aol.com> | 2026-08-23 17:20:00 +0100 |
| commit | da1ea35fea67ad841f4ada28dd61b41be65e5437 (patch) | |
| tree | ccf32e34e28610d79c81a9fbd058c2d679ee7db8 /drivers/gpu | |
| parent | 500cb24cd61bad8a2747ddfc49b7034899c82d94 (diff) | |
| download | linux-next-da1ea35fea67ad841f4ada28dd61b41be65e5437.tar.gz linux-next-da1ea35fea67ad841f4ada28dd61b41be65e5437.zip | |
drm/gud: validate TV mode names before creating enum property
The GUD protocol returns TV mode names as fixed-size
GUD_CONNECTOR_TV_MODE_NAME_LEN entries and requires each name to be
NUL-terminated.
gud_connector_add_tv_mode() currently passes each fixed-size entry
directly to drm_mode_create_tv_properties_legacy(), which eventually
reaches drm_property_add_enum() and strlen(). If a device returns an
entry without a terminating NUL byte, strlen() reads past the end of
the slot and can run beyond the allocated buffer, triggering an
out-of-bounds read.
Validate that each returned TV mode name contains a NUL terminator
within its fixed-size slot before passing it to the DRM property code.
If a malformed entry is found, reject the device response with -EIO.
This fixes the out-of-bounds read without changing the handling of
valid devices, and avoids silently truncating malformed protocol data.
Reported-by: syzbot+9ae8e7884e451eaed5b4@syzkaller.appspotmail.com
Fixes: 40e1a70b4aed ("drm: Add GUD USB Display driver")
Signed-off-by: Tao Yu <tao1.yu@intel.com>
Reviewed-by: Ruben Wauters <rubenru09@aol.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Ruben Wauters <rubenru09@aol.com>
Link: https://patch.msgid.link/20260819072835.4074130-1-tao1.yu@intel.com
Diffstat (limited to 'drivers/gpu')
| -rw-r--r-- | drivers/gpu/drm/gud/gud_connector.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/gpu/drm/gud/gud_connector.c b/drivers/gpu/drm/gud/gud_connector.c index 5c0065c876a7..8141c3a1e30a 100644 --- a/drivers/gpu/drm/gud/gud_connector.c +++ b/drivers/gpu/drm/gud/gud_connector.c @@ -399,8 +399,11 @@ static int gud_connector_add_tv_mode(struct gud_device *gdrm, struct drm_connect for (i = 0; i < num_modes; i++) { char *mode = &buf[i * GUD_CONNECTOR_TV_MODE_NAME_LEN]; - /* The device is not trusted to NUL-terminate the name */ - mode[GUD_CONNECTOR_TV_MODE_NAME_LEN - 1] = '\0'; + if (!memchr(mode, '\0', GUD_CONNECTOR_TV_MODE_NAME_LEN)) { + ret = -EIO; + goto free; + } + modes[i] = mode; } |
