From: Chris Wilson Date: Mon, 4 Dec 2017 03:23:44 +0000 (+0800) Subject: drm/i915/gvt: Fix out-of-bounds buffer write into opregion->signature[] X-Git-Tag: v4.19~298^2~46^2~859^2~31 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ea26c96d59b27e878fe61e8ef0fed840d2281a2f;p=platform%2Fkernel%2Flinux-rpi.git 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: b2d6ef70614e ("drm/i915/gvt: Let each vgpu has separate opregion memory") Signed-off-by: Chris Wilson Cc: Xiong Zhang Cc: Zhenyu Wang Cc: Zhi Wang Cc: intel-gvt-dev@lists.freedesktop.org Signed-off-by: Zhenyu Wang --- diff --git a/drivers/gpu/drm/i915/gvt/opregion.c b/drivers/gpu/drm/i915/gvt/opregion.c index 80720e5..bf8e5c4 100644 --- a/drivers/gpu/drm/i915/gvt/opregion.c +++ b/drivers/gpu/drm/i915/gvt/opregion.c @@ -218,6 +218,7 @@ static int alloc_and_init_virt_opregion(struct intel_vgpu *vgpu) u8 *buf; struct opregion_header *header; struct vbt v; + const char opregion_signature[16] = OPREGION_SIGNATURE; gvt_dbg_core("init vgpu%d opregion\n", vgpu->id); 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) /* emulated opregion with VBT mailbox only */ buf = (u8 *)vgpu_opregion(vgpu)->va; header = (struct opregion_header *)buf; - memcpy(header->signature, OPREGION_SIGNATURE, - sizeof(OPREGION_SIGNATURE)); + memcpy(header->signature, opregion_signature, + sizeof(opregion_signature)); header->size = 0x8; header->opregion_ver = 0x02000000; header->mboxes = MBOX_VBT;