Commit ea26c96d authored by Chris Wilson's avatar Chris Wilson Committed by Zhenyu Wang

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: b2d6ef70 ("drm/i915/gvt: Let each vgpu has separate opregion memory")
Signed-off-by: default avatarChris 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: default avatarZhenyu Wang <zhenyuw@linux.intel.com>
parent 7b302556
...@@ -218,6 +218,7 @@ static int alloc_and_init_virt_opregion(struct intel_vgpu *vgpu) ...@@ -218,6 +218,7 @@ static int alloc_and_init_virt_opregion(struct intel_vgpu *vgpu)
u8 *buf; u8 *buf;
struct opregion_header *header; struct opregion_header *header;
struct vbt v; struct vbt v;
const char opregion_signature[16] = OPREGION_SIGNATURE;
gvt_dbg_core("init vgpu%d opregion\n", vgpu->id); gvt_dbg_core("init vgpu%d opregion\n", vgpu->id);
vgpu_opregion(vgpu)->va = (void *)__get_free_pages(GFP_KERNEL | 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) ...@@ -231,8 +232,8 @@ static int alloc_and_init_virt_opregion(struct intel_vgpu *vgpu)
/* emulated opregion with VBT mailbox only */ /* emulated opregion with VBT mailbox only */
buf = (u8 *)vgpu_opregion(vgpu)->va; buf = (u8 *)vgpu_opregion(vgpu)->va;
header = (struct opregion_header *)buf; header = (struct opregion_header *)buf;
memcpy(header->signature, OPREGION_SIGNATURE, memcpy(header->signature, opregion_signature,
sizeof(OPREGION_SIGNATURE)); sizeof(opregion_signature));
header->size = 0x8; header->size = 0x8;
header->opregion_ver = 0x02000000; header->opregion_ver = 0x02000000;
header->mboxes = MBOX_VBT; header->mboxes = MBOX_VBT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment