drm/radeon: Prefer strscpy over strlcpy in 'radeon_combios_get_power_modes'
authorSrinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Wed, 26 Jul 2023 14:42:11 +0000 (20:12 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 27 Jul 2023 18:59:30 +0000 (14:59 -0400)
commit9eec1fc150094857887f44ead59a2c896fbff6d3
treec5f75383f5d0366586929eced172e0bb08adeee3
parent6cf20211fc59fcb0bf9b05d4c703cb1e93b167a1
drm/radeon: Prefer strscpy over strlcpy in 'radeon_combios_get_power_modes'

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. The safe
replacement is strscpy() [1].

cleanup to remove the strlcpy() function entirely from the kernel [2].

[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy
[2] https://github.com/KSPP/linux/issues/89

Fixes the following:

WARNING: Prefer strscpy over strlcpy
+                               strlcpy(info.type, name, sizeof(info.type));

WARNING: Prefer strscpy over strlcpy
+                               strlcpy(info.type, name, sizeof(info.type));

Cc: Guchun Chen <guchun.chen@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/radeon/radeon_combios.c