mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-30 22:03:17 +01:00
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: [email protected]
Fixes: 40e1a70b4a ("drm: Add GUD USB Display driver")
Signed-off-by: Tao Yu <[email protected]>
Reviewed-by: Ruben Wauters <[email protected]>
Cc: <[email protected]>
Signed-off-by: Ruben Wauters <[email protected]>
Link: https://patch.msgid.link/[email protected]
This commit is contained in:
1 parent
500cb24cd6
commit
da1ea35fea
1 file changed
+5
-2
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user