Skip to content

Commit 533950d

Browse files
azeemshaikh38kees
authored andcommitted
drm/display/dp_mst: Replace all non-returning strlcpy with strscpy
strlcpy() reads the entire source buffer first. This read may exceed the destination size limit. This is both inefficient and can lead to linear read overflows if a source string is not NUL-terminated [1]. In an effort to remove strlcpy() completely [2], replace strlcpy() here with strscpy(). No return values were used, so direct replacement is safe. [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy [2] KSPP#89 Signed-off-by: Azeem Shaikh <[email protected]> Reviewed-by: Kees Cook <[email protected]> Signed-off-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 26f15e5 commit 533950d

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

drivers/gpu/drm/display/drm_dp_helper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2103,7 +2103,7 @@ int drm_dp_aux_register(struct drm_dp_aux *aux)
21032103
aux->ddc.owner = THIS_MODULE;
21042104
aux->ddc.dev.parent = aux->dev;
21052105

2106-
strlcpy(aux->ddc.name, aux->name ? aux->name : dev_name(aux->dev),
2106+
strscpy(aux->ddc.name, aux->name ? aux->name : dev_name(aux->dev),
21072107
sizeof(aux->ddc.name));
21082108

21092109
ret = drm_dp_aux_register_devnode(aux);

drivers/gpu/drm/display/drm_dp_mst_topology.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5702,7 +5702,7 @@ static int drm_dp_mst_register_i2c_bus(struct drm_dp_mst_port *port)
57025702
aux->ddc.dev.parent = parent_dev;
57035703
aux->ddc.dev.of_node = parent_dev->of_node;
57045704

5705-
strlcpy(aux->ddc.name, aux->name ? aux->name : dev_name(parent_dev),
5705+
strscpy(aux->ddc.name, aux->name ? aux->name : dev_name(parent_dev),
57065706
sizeof(aux->ddc.name));
57075707

57085708
return i2c_add_adapter(&aux->ddc);

drivers/gpu/drm/drm_mipi_dsi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ mipi_dsi_device_register_full(struct mipi_dsi_host *host,
223223

224224
device_set_node(&dsi->dev, of_fwnode_handle(info->node));
225225
dsi->channel = info->channel;
226-
strlcpy(dsi->name, info->type, sizeof(dsi->name));
226+
strscpy(dsi->name, info->type, sizeof(dsi->name));
227227

228228
ret = mipi_dsi_device_add(dsi);
229229
if (ret) {

0 commit comments

Comments
 (0)