Skip to content

Commit ea26c96

Browse files
icklezhenyw
authored andcommitted
drm/i915/gvt: Fix out-of-bounds buffer write into opregion->signature[]
sparse spots drivers/gpu/drm/i915/gvt/opregion.c:234 alloc_and_init_virt_opregion() error: memcpy() 'header->signature' too small (16 vs 17) as gvt is indeed trying to memcpy a string longer than the signature[]. Fixes: b2d6ef7 ("drm/i915/gvt: Let each vgpu has separate opregion memory") Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Xiong Zhang <xiong.y.zhang@intel.com> Cc: Zhenyu Wang <zhenyuw@linux.intel.com> Cc: Zhi Wang <zhi.a.wang@intel.com> Cc: intel-gvt-dev@lists.freedesktop.org Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
1 parent 7b30255 commit ea26c96

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/gpu/drm/i915/gvt/opregion.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ static int alloc_and_init_virt_opregion(struct intel_vgpu *vgpu)
218218
u8 *buf;
219219
struct opregion_header *header;
220220
struct vbt v;
221+
const char opregion_signature[16] = OPREGION_SIGNATURE;
221222

222223
gvt_dbg_core("init vgpu%d opregion\n", vgpu->id);
223224
vgpu_opregion(vgpu)->va = (void *)__get_free_pages(GFP_KERNEL |
@@ -231,8 +232,8 @@ static int alloc_and_init_virt_opregion(struct intel_vgpu *vgpu)
231232
/* emulated opregion with VBT mailbox only */
232233
buf = (u8 *)vgpu_opregion(vgpu)->va;
233234
header = (struct opregion_header *)buf;
234-
memcpy(header->signature, OPREGION_SIGNATURE,
235-
sizeof(OPREGION_SIGNATURE));
235+
memcpy(header->signature, opregion_signature,
236+
sizeof(opregion_signature));
236237
header->size = 0x8;
237238
header->opregion_ver = 0x02000000;
238239
header->mboxes = MBOX_VBT;

0 commit comments

Comments
 (0)