* [PATCH] drm/amdgpu: Replace deprecated strcpy() in amdgpu_virt_write_vf2pf_data
@ 2026-01-09 16:25 Yicong Hui
2026-01-09 19:18 ` Kees Cook
0 siblings, 1 reply; 4+ messages in thread
From: Yicong Hui @ 2026-01-09 16:25 UTC (permalink / raw)
To: alexander.deucher, christian.koenig, airlied, simona
Cc: amd-gfx, dri-devel, skhan, david.hunter.linux, linux-hardening,
Yicong Hui
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.
Signed-off-by: Yicong Hui <yiconghui@gmail.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
index 47a6ce4fdc74..1c4e74e35cf3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
@@ -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;
--
2.52.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] drm/amdgpu: Replace deprecated strcpy() in amdgpu_virt_write_vf2pf_data
2026-01-09 16:25 [PATCH] drm/amdgpu: Replace deprecated strcpy() in amdgpu_virt_write_vf2pf_data Yicong Hui
@ 2026-01-09 19:18 ` Kees Cook
2026-03-11 11:52 ` Yicong Hui
0 siblings, 1 reply; 4+ messages in thread
From: Kees Cook @ 2026-01-09 19:18 UTC (permalink / raw)
To: Yicong Hui
Cc: alexander.deucher, christian.koenig, airlied, simona, amd-gfx,
dri-devel, skhan, david.hunter.linux, linux-hardening
On Fri, Jan 09, 2026 at 04:25:14PM +0000, Yicong Hui wrote:
> 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.
This looks correct to me -- dest and src are both fixed-size, so strscpy
happily checks everything at compile time. :)
Reviewed-by: Kees Cook <kees@kernel.org>
-Kees
--
Kees Cook
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drm/amdgpu: Replace deprecated strcpy() in amdgpu_virt_write_vf2pf_data
2026-01-09 19:18 ` Kees Cook
@ 2026-03-11 11:52 ` Yicong Hui
2026-03-11 13:50 ` Alex Deucher
0 siblings, 1 reply; 4+ messages in thread
From: Yicong Hui @ 2026-03-11 11:52 UTC (permalink / raw)
To: Kees Cook, airlied, christian.koenig, alexander.deucher, simona
Cc: amd-gfx, dri-devel, skhan, david.hunter.linux, linux-hardening
On 1/9/26 7:18 PM, Kees Cook wrote:
> On Fri, Jan 09, 2026 at 04:25:14PM +0000, Yicong Hui wrote:
>> 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.
>
> This looks correct to me -- dest and src are both fixed-size, so strscpy
> happily checks everything at compile time. :)
>
> Reviewed-by: Kees Cook <kees@kernel.org>
>
> -Kees
>
Hello!
Is there any further feedback or progress on this patch?
Thank you!
Yicong
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drm/amdgpu: Replace deprecated strcpy() in amdgpu_virt_write_vf2pf_data
2026-03-11 11:52 ` Yicong Hui
@ 2026-03-11 13:50 ` Alex Deucher
0 siblings, 0 replies; 4+ messages in thread
From: Alex Deucher @ 2026-03-11 13:50 UTC (permalink / raw)
To: Yicong Hui
Cc: Kees Cook, airlied, christian.koenig, alexander.deucher, simona,
amd-gfx, dri-devel, skhan, david.hunter.linux, linux-hardening
On Wed, Mar 11, 2026 at 7:59 AM Yicong Hui <yiconghui@gmail.com> wrote:
>
> On 1/9/26 7:18 PM, Kees Cook wrote:
> > On Fri, Jan 09, 2026 at 04:25:14PM +0000, Yicong Hui wrote:
> >> 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.
> >
> > This looks correct to me -- dest and src are both fixed-size, so strscpy
> > happily checks everything at compile time. :)
> >
> > Reviewed-by: Kees Cook <kees@kernel.org>
> >
> > -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
>
> Thank you!
> Yicong
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-03-11 13:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-09 16:25 [PATCH] drm/amdgpu: Replace deprecated strcpy() in amdgpu_virt_write_vf2pf_data Yicong Hui
2026-01-09 19:18 ` Kees Cook
2026-03-11 11:52 ` Yicong Hui
2026-03-11 13:50 ` Alex Deucher
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox