drm/amdgpu: Replace deprecated strcpy() in amdgpu_virt_write_vf2pf_data
Subsystems (2)
PATCH 1/1 drm/amdgpu: Replace deprecated strcpy() in amdgpu_virt_write_vf2pf_data
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.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +2 -2
@@ -604,10 +604,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 ;
Signature · 1 line
2.52.0
Quoted 9 lines · Yicong Hui
strcpy()is deprecated as it does not do any bounds checking (as specified inDocumentation/process/deprecated.rst).There is a risk of buffer overflow in the case that the value for
THIS_MODULE->versionexceeds 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 saferstrscpy()function.
This looks correct to me -- dest and src are both fixed-size, so strscpy happily checks everything at compile time. :)
-Kees
Signature · 1 line
Kees Cook
Quoted 9 lines · Kees Cook
Quoted 8 lines · Yicong Hui
strcpy()is deprecated as it does not do any bounds checking (as specified inDocumentation/process/deprecated.rst).There is a risk of buffer overflow in the case that the value for
THIS_MODULE->versionexceeds the 64 characters. This is unlikely, but replacing the deprecated function will pre-emptively remove this risk entirely.
Quoted 9 lines
Quoted 1 line
Replace both instances of
strcpy()with the saferstrscpy()function.This looks correct to me -- dest and src are both fixed-size, so strscpy happily checks everything at compile time. :)
Reviewed-by Kees Cook <[email protected]>-Kees
Hello!
Is there any further feedback or progress on this patch?
Thank you!
Yicong
Alex Deucher
AppliedQuoted 16 lines · Yicong Hui
Quoted 14 lines · Kees Cook
Quoted 9 lines · Yicong Hui
strcpy()is deprecated as it does not do any bounds checking (as specified inDocumentation/process/deprecated.rst).There is a risk of buffer overflow in the case that the value for
THIS_MODULE->versionexceeds 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 saferstrscpy()function.This looks correct to me -- dest and src are both fixed-size, so strscpy happily checks everything at compile time. :)
Quoted 8 lines
Quoted 4 lines
Reviewed-by Kees Cook <[email protected]>-Kees
Hello!
Is there any further feedback or progress on this patch?
Applied. Thanks. If any other patches slipped through the cracks, please feel free to resend or ping on them.
Alex
Quoted 3 lines
Thank you!
Yicong