Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/radeon: 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] https://github.com/KSPP/linux/issues/89

Signed-off-by: Azeem Shaikh <azeemshaikh38@gmail.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20230522155032.2336283-1-azeemshaikh38@gmail.com

authored by

Azeem Shaikh and committed by
Kees Cook
992b8fe1 c7dce4c5

+5 -5
+1 -1
drivers/gpu/drm/amd/amdgpu/atom.c
··· 1509 1509 str = CSTR(idx); 1510 1510 if (*str != '\0') { 1511 1511 pr_info("ATOM BIOS: %s\n", str); 1512 - strlcpy(ctx->vbios_version, str, sizeof(ctx->vbios_version)); 1512 + strscpy(ctx->vbios_version, str, sizeof(ctx->vbios_version)); 1513 1513 } 1514 1514 1515 1515 atom_rom_header = (struct _ATOM_ROM_HEADER *)CSTR(base);
+2 -2
drivers/gpu/drm/radeon/radeon_atombios.c
··· 2105 2105 const char *name = thermal_controller_names[power_info->info. 2106 2106 ucOverdriveThermalController]; 2107 2107 info.addr = power_info->info.ucOverdriveControllerAddress >> 1; 2108 - strlcpy(info.type, name, sizeof(info.type)); 2108 + strscpy(info.type, name, sizeof(info.type)); 2109 2109 i2c_new_client_device(&rdev->pm.i2c_bus->adapter, &info); 2110 2110 } 2111 2111 } ··· 2355 2355 struct i2c_board_info info = { }; 2356 2356 const char *name = pp_lib_thermal_controller_names[controller->ucType]; 2357 2357 info.addr = controller->ucI2cAddress >> 1; 2358 - strlcpy(info.type, name, sizeof(info.type)); 2358 + strscpy(info.type, name, sizeof(info.type)); 2359 2359 i2c_new_client_device(&rdev->pm.i2c_bus->adapter, &info); 2360 2360 } 2361 2361 } else {
+2 -2
drivers/gpu/drm/radeon/radeon_combios.c
··· 2702 2702 struct i2c_board_info info = { }; 2703 2703 const char *name = thermal_controller_names[thermal_controller]; 2704 2704 info.addr = i2c_addr >> 1; 2705 - strlcpy(info.type, name, sizeof(info.type)); 2705 + strscpy(info.type, name, sizeof(info.type)); 2706 2706 i2c_new_client_device(&rdev->pm.i2c_bus->adapter, &info); 2707 2707 } 2708 2708 } ··· 2719 2719 struct i2c_board_info info = { }; 2720 2720 const char *name = "f75375"; 2721 2721 info.addr = 0x28; 2722 - strlcpy(info.type, name, sizeof(info.type)); 2722 + strscpy(info.type, name, sizeof(info.type)); 2723 2723 i2c_new_client_device(&rdev->pm.i2c_bus->adapter, &info); 2724 2724 DRM_INFO("Possible %s thermal controller at 0x%02x\n", 2725 2725 name, info.addr);