drm/i915/gvt: use strscpy() instead of strcpy() in virt_vbt_generation()
PATCH 1/1 drm/i915/gvt: use strscpy() instead of strcpy() in virt_vbt_generation()
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.
--- drivers/gpu/drm/i915/gvt/opregion.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/gvt/opregion.c +2 -1
@@ -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);
Quoted 17 lines · On Tue, 1 Sep 2026 10:32:41 +0530 Hrushiraj Gandhi <[email protected]>…
strcpy()has no bound on the destination buffer, so convert this to the bounded, always-NUL-terminatingstrscpy()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 <[email protected]>--- drivers/gpu/drm/i915/gvt/opregion.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/gvt/opregion.c +0
-0
drivers/gpu/drm/i915/gvt/opregion.c static void virt_vbt_generation(struct vbt *v) · line 155
Quoted 6 lines
drivers/gpu/drm/i915/gvt/opregion.c +2
-1@@ -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
Quoted 4 lines
drivers/gpu/drm/i915/gvt/opregion.c +0
-0v->bdb_header.version =186 ;/* child_dev_size = 33 */ v->bdb_header.header_size =sizeof (v->bdb_header);
Jani Nikula
maintainerQuoted 23 lines · David Laight
Quoted 20 lines · On Tue, 1 Sep 2026 10:32:41 +0530 Hrushiraj Gandhi <[email protected]>…
strcpy()has no bound on the destination buffer, so convert this to the bounded, always-NUL-terminatingstrscpy()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 <[email protected]>--- drivers/gpu/drm/i915/gvt/opregion.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/gvt/opregion.c +0
-0@@ -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);
Quoted 8 lines
drivers/gpu/drm/i915/gvt/opregion.c static void virt_vbt_generation(struct vbt *v) · line 155
Quoted 3 lines
drivers/gpu/drm/i915/gvt/opregion.c +2
-1-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 samememcpy()call.
If the fixed string is too longstrcpy()generates a compile error whereasstrscpy()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.
Quoted 10 lines
(The '&' and '[0]' might need removing.)
David
Quoted 4 lines
drivers/gpu/drm/i915/gvt/opregion.c +0
-0v->bdb_header.version =186 ;/* child_dev_size = 33 */ v->bdb_header.header_size =sizeof (v->bdb_header);
Signature · 1 line
Jani Nikula, Intel
Patchwork
CI✗ LGCI.VerificationFailed: failure for drm/i915/gvt: use strscpy() instead of strcpy() in virt_vbt_generation()
In reply to Hrushiraj Gandhi== Series Details ==
== 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 '[email protected]' 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)