]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/amdgpu: Replace deprecated strcpy() in amdgpu_virt_write_vf2pf_data
authorYicong Hui <yiconghui@gmail.com>
Fri, 9 Jan 2026 16:25:14 +0000 (16:25 +0000)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 17 Mar 2026 14:40:51 +0000 (10:40 -0400)
strcpy() is deprecated as it does not do any bounds checking (as
specified in Documentation/process/deprecated.rst).

There is a risk of buffer overflow in the case that the value for
THIS_MODULE->version exceeds the 64 characters. This is unlikely, but
replacing the deprecated function will pre-emptively remove this risk
entirely.

Replace both instances of strcpy() with the safer strscpy() function.

Changes have been compile tested.

Reviewed-by: Kees Cook <kees@kernel.org>
Signed-off-by: Yicong Hui <yiconghui@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c

index 275745aa5829292d4b3a96ac11777f6bbd56e9a5..8a8ff8a70d25f8082bfa63b15e6dd195b263eb95 100644 (file)
@@ -605,10 +605,10 @@ static int amdgpu_virt_write_vf2pf_data(struct amdgpu_device *adev)
 
 #ifdef MODULE
        if (THIS_MODULE->version != NULL)
-               strcpy(vf2pf_info->driver_version, THIS_MODULE->version);
+               strscpy(vf2pf_info->driver_version, THIS_MODULE->version);
        else
 #endif
-               strcpy(vf2pf_info->driver_version, "N/A");
+               strscpy(vf2pf_info->driver_version, "N/A");
 
        vf2pf_info->pf2vf_version_required = 0; // no requirement, guest understands all
        vf2pf_info->driver_cert = 0;