* [PATCH] drm/i915/gvt: use strscpy() instead of strcpy() in virt_vbt_generation()
@ 2026-09-01 5:02 Hrushiraj Gandhi
2026-09-01 9:12 ` David Laight
2026-09-01 16:22 ` ✗ LGCI.VerificationFailed: failure for " Patchwork
0 siblings, 2 replies; 4+ messages in thread
From: Hrushiraj Gandhi @ 2026-09-01 5:02 UTC (permalink / raw)
To: jani.nikula, joonas.lahtinen, rodrigo.vivi, tursulin
Cc: intel-gfx, dri-devel, linux-kernel, Hrushiraj Gandhi
strcpy() has no bound on the destination buffer, so convert this to
the bounded, always-NUL-terminating strscpy() instead. The literal
"BIOS_DATA_BLOCK" (15 chars + NUL) fits the 16-byte signature field
exactly, so this is a no-op change in behaviour.
No functional change.
Signed-off-by: Hrushiraj Gandhi <hrushirajg23@gmail.com>
---
drivers/gpu/drm/i915/gvt/opregion.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/i915/gvt/opregion.c b/drivers/gpu/drm/i915/gvt/opregion.c
index d6e76ba31d60..f2527e26cd1e 100644
--- a/drivers/gpu/drm/i915/gvt/opregion.c
+++ b/drivers/gpu/drm/i915/gvt/opregion.c
@@ -151,7 +151,8 @@ static void virt_vbt_generation(struct vbt *v)
v->header.vbt_size = sizeof(struct vbt);
v->header.bdb_offset = offsetof(struct vbt, bdb_header);
- strcpy(&v->bdb_header.signature[0], "BIOS_DATA_BLOCK");
+ strscpy(v->bdb_header.signature, "BIOS_DATA_BLOCK",
+ sizeof(v->bdb_header.signature));
v->bdb_header.version = 186; /* child_dev_size = 33 */
v->bdb_header.header_size = sizeof(v->bdb_header);
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] drm/i915/gvt: use strscpy() instead of strcpy() in virt_vbt_generation()
2026-09-01 5:02 [PATCH] drm/i915/gvt: use strscpy() instead of strcpy() in virt_vbt_generation() Hrushiraj Gandhi
@ 2026-09-01 9:12 ` David Laight
2026-09-01 10:29 ` Jani Nikula
2026-09-01 16:22 ` ✗ LGCI.VerificationFailed: failure for " Patchwork
1 sibling, 1 reply; 4+ messages in thread
From: David Laight @ 2026-09-01 9:12 UTC (permalink / raw)
To: Hrushiraj Gandhi
Cc: jani.nikula, joonas.lahtinen, rodrigo.vivi, tursulin, intel-gfx,
dri-devel, linux-kernel
On Tue, 1 Sep 2026 10:32:41 +0530
Hrushiraj Gandhi <hrushirajg23@gmail.com> wrote:
> strcpy() has no bound on the destination buffer, so convert this to
> the bounded, always-NUL-terminating strscpy() instead. The literal
> "BIOS_DATA_BLOCK" (15 chars + NUL) fits the 16-byte signature field
> exactly, so this is a no-op change in behaviour.
>
> No functional change.
>
> Signed-off-by: Hrushiraj Gandhi <hrushirajg23@gmail.com>
> ---
> drivers/gpu/drm/i915/gvt/opregion.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/gvt/opregion.c b/drivers/gpu/drm/i915/gvt/opregion.c
> index d6e76ba31d60..f2527e26cd1e 100644
> --- a/drivers/gpu/drm/i915/gvt/opregion.c
> +++ b/drivers/gpu/drm/i915/gvt/opregion.c
> @@ -151,7 +151,8 @@ static void virt_vbt_generation(struct vbt *v)
> v->header.vbt_size = sizeof(struct vbt);
> v->header.bdb_offset = offsetof(struct vbt, bdb_header);
>
> - strcpy(&v->bdb_header.signature[0], "BIOS_DATA_BLOCK");
> + strscpy(v->bdb_header.signature, "BIOS_DATA_BLOCK",
> + sizeof(v->bdb_header.signature));
Pointless and potentially wrong.
Both normally reduce to the same memcpy() call.
If the fixed string is too long strcpy() generates a compile error
whereas strscpy() will silently truncate.
(The '&' and '[0]' might need removing.)
David
> v->bdb_header.version = 186; /* child_dev_size = 33 */
> v->bdb_header.header_size = sizeof(v->bdb_header);
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drm/i915/gvt: use strscpy() instead of strcpy() in virt_vbt_generation()
2026-09-01 9:12 ` David Laight
@ 2026-09-01 10:29 ` Jani Nikula
0 siblings, 0 replies; 4+ messages in thread
From: Jani Nikula @ 2026-09-01 10:29 UTC (permalink / raw)
To: David Laight, Hrushiraj Gandhi
Cc: joonas.lahtinen, rodrigo.vivi, tursulin, intel-gfx, dri-devel,
linux-kernel
On Tue, 01 Sep 2026, David Laight <david.laight.linux@gmail.com> wrote:
> On Tue, 1 Sep 2026 10:32:41 +0530
> Hrushiraj Gandhi <hrushirajg23@gmail.com> wrote:
>
>> strcpy() has no bound on the destination buffer, so convert this to
>> the bounded, always-NUL-terminating strscpy() instead. The literal
>> "BIOS_DATA_BLOCK" (15 chars + NUL) fits the 16-byte signature field
>> exactly, so this is a no-op change in behaviour.
>>
>> No functional change.
>>
>> Signed-off-by: Hrushiraj Gandhi <hrushirajg23@gmail.com>
>> ---
>> drivers/gpu/drm/i915/gvt/opregion.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/i915/gvt/opregion.c b/drivers/gpu/drm/i915/gvt/opregion.c
>> index d6e76ba31d60..f2527e26cd1e 100644
>> --- a/drivers/gpu/drm/i915/gvt/opregion.c
>> +++ b/drivers/gpu/drm/i915/gvt/opregion.c
>> @@ -151,7 +151,8 @@ static void virt_vbt_generation(struct vbt *v)
>> v->header.vbt_size = sizeof(struct vbt);
>> v->header.bdb_offset = offsetof(struct vbt, bdb_header);
>>
>> - strcpy(&v->bdb_header.signature[0], "BIOS_DATA_BLOCK");
>> + strscpy(v->bdb_header.signature, "BIOS_DATA_BLOCK",
>> + sizeof(v->bdb_header.signature));
>
> Pointless and potentially wrong.
> Both normally reduce to the same memcpy() call.
> If the fixed string is too long strcpy() generates a compile error
> whereas strscpy() will silently truncate.
Moreover, there's no provision that the signature must be NUL
terminated. All consumers must treat it as a 16-byte block which may or
may not be NUL terminated. In fact, it is usually padded with space
rather than NUL terminated, and one could argue the NUL termination is
wrong here.
BR,
Jani.
>
> (The '&' and '[0]' might need removing.)
>
> David
>
>> v->bdb_header.version = 186; /* child_dev_size = 33 */
>> v->bdb_header.header_size = sizeof(v->bdb_header);
>>
>>
>
--
Jani Nikula, Intel
^ permalink raw reply [flat|nested] 4+ messages in thread
* ✗ LGCI.VerificationFailed: failure for drm/i915/gvt: use strscpy() instead of strcpy() in virt_vbt_generation()
2026-09-01 5:02 [PATCH] drm/i915/gvt: use strscpy() instead of strcpy() in virt_vbt_generation() Hrushiraj Gandhi
2026-09-01 9:12 ` David Laight
@ 2026-09-01 16:22 ` Patchwork
1 sibling, 0 replies; 4+ messages in thread
From: Patchwork @ 2026-09-01 16:22 UTC (permalink / raw)
To: Hrushiraj Gandhi; +Cc: intel-gfx
== Series Details ==
Series: drm/i915/gvt: use strscpy() instead of strcpy() in virt_vbt_generation()
URL : https://patchwork.freedesktop.org/series/173157/
State : failure
== Summary ==
Series author address 'hrushirajg23@gmail.com' is not on the allowlist, which prevents CI from being automatically triggered.
If you want CI to run for this series, ask Patchwork project owners to click 'retest' on the series in Patchwork.
Exception occurred during validation, bailing out!
Build URL: http://gfx-ci.igk.intel.com:8080/job/CI_PW_kernel/186501/ (on built-in)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-09-01 16:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-01 5:02 [PATCH] drm/i915/gvt: use strscpy() instead of strcpy() in virt_vbt_generation() Hrushiraj Gandhi
2026-09-01 9:12 ` David Laight
2026-09-01 10:29 ` Jani Nikula
2026-09-01 16:22 ` ✗ LGCI.VerificationFailed: failure for " Patchwork
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox