Re: [PATCH] drm/gud: NUL-terminate TV mode names read from the device

Ruben Wauters <[email protected]>
Newsgroups org.freedesktop.lists.dri-devel,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On Mon, 2026-08-17 at 16:36 +0100, Ruben Wauters wrote:
> On Sun, 2026-08-16 at 14:22 +0530, Deepanshu Kartikey wrote:
> > gud_connector_add_tv_mode() reads a buffer of fixed-size mode names from
> > the USB device and passes pointers into it to
> > drm_mode_create_tv_properties_legacy(), which calls strlen() on each one.
> > Nothing guarantees the device NUL-terminates a name, so strlen() can run
> > past the end of a slot and, for the last mode, past the end of the
> > allocation.
> > 
> > Terminate each name at the end of its slot before use.
> > 
> > Fixes: 40e1a70b4aed ("drm: Add GUD USB Display driver")
> > Reported-by: [email protected]
> > Closes: https://syzkaller.appspot.com/bug?extid=916c888ba5f1a54c9526
> > Tested-by: [email protected]
> > Signed-off-by: Deepanshu Kartikey <[email protected]>
> Acked-by: Ruben Wauters <[email protected]>

Thank you, applied to drm-misc-fixes, Cc'd stable

Ruben
> > ---
> >  drivers/gpu/drm/gud/gud_connector.c | 9 +++++++--
> >  1 file changed, 7 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/gud/gud_connector.c b/drivers/gpu/drm/gud/gud_connector.c
> > index ea0cca58b7c8..5c0065c876a7 100644
> > --- a/drivers/gpu/drm/gud/gud_connector.c
> > +++ b/drivers/gpu/drm/gud/gud_connector.c
> > @@ -396,8 +396,13 @@ 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];
> > +
> > +		/* The device is not trusted to NUL-terminate the name */
> > +		mode[GUD_CONNECTOR_TV_MODE_NAME_LEN - 1] = '\0';
> > +		modes[i] = mode;
> > +	}
> >  
> >  	ret = drm_mode_create_tv_properties_legacy(connector->dev, num_modes, modes);
> >  free:
signature.asc (application/pgp-signature, 870 B)
-----BEGIN PGP SIGNATURE-----

iQJPBAABCAA5FiEE3obNNdPQ9V5CQi2Y0n5QwFCuDOEFAmqLFKYbFIAAAAAABAAO
bWFudTIsMi41KzEuMTIsMiwyAAoJENJ+UMBQrgzhR+sP/RIIZHGDZNC/YBrZ2kHQ
Y47mb666c8c9OgnXOQElwPhTilOPpM8IpasomfG76FOSRh/jT4gZoLxQcVWXlwDF
+2GUP92L6ZkHDgh0ELEKlUSgxERnP53VsucrsmpN5p9Tec0RKTXrD2mF+eL9h15A
BbJzKkc/aO9av2I348mNPumS/eRnWI8nMVJU0VMb3O/w7abNX7Gvh8Tlsoj5Aj/n
5WtRqZdlJd7pZNwhZfpi3HULNny5Rp/ZPckN+qUZAnGqMRmoUNLGhBLQoxBxJUdf
LGfYrSdCAhRFJiQDnfEDOpr8JIyzpAiI4NyBW9wqqJeKaCGk/791N/657sd6GJzW
+YQvjCPj5qenBzs/ISYCO4K5yYH2L1optibjBTcFGSLYG+M5lXLrKQdfmIun03au
zDrHa+iq6X22tPJWDUAZ1QsCJGo4GVnmkmC+/aE5xogAxYtZVk5lREvQU9Eey+CC
OspH4P3C3quTQWGo2UdzKgCegp9l/T47oX4YjP/UIA7qyfyTFwKbCt0WBaxAxB6r
XVt1+6fxBXTDM7uGvdvuqJMie8DzHee0oKIy+qiUN0qolcP2X819vBI3+LiKqT4+
Wz63sPv5+hZR8Dxq06ZcF0Vl0MHVMi6M/RUacuA3riXO2v/CUVigZky9CdBTCAI7
1SZl840i3619OtEXy2OCD3HQ
=DN5a
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.