|
|
99cbc7 |
From bcaa73c80a8634c7db6e7b3a90f2f56b0817bfc5 Mon Sep 17 00:00:00 2001
|
|
|
99cbc7 |
Message-Id: <bcaa73c80a8634c7db6e7b3a90f2f56b0817bfc5@dist-git>
|
|
|
99cbc7 |
From: Michal Privoznik <mprivozn@redhat.com>
|
|
|
99cbc7 |
Date: Thu, 7 Mar 2019 14:17:01 +0100
|
|
|
99cbc7 |
Subject: [PATCH] cpu: Don't access invalid memory in virCPUx86Translate
|
|
|
99cbc7 |
MIME-Version: 1.0
|
|
|
99cbc7 |
Content-Type: text/plain; charset=UTF-8
|
|
|
99cbc7 |
Content-Transfer-Encoding: 8bit
|
|
|
99cbc7 |
|
|
|
99cbc7 |
Problem is that if there are no signatures for a CPU, then we
|
|
|
99cbc7 |
still allocate cpu->signatures (even though with size 0). Later,
|
|
|
99cbc7 |
we access cpu->signatures[0] if cpu->signatures is not NULL.
|
|
|
99cbc7 |
|
|
|
99cbc7 |
Invalid read of size 4
|
|
|
99cbc7 |
at 0x5F439D7: virCPUx86Translate (cpu_x86.c:2930)
|
|
|
99cbc7 |
by 0x5F3C239: virCPUTranslate (cpu.c:927)
|
|
|
99cbc7 |
by 0x57CE7A1: qemuProcessUpdateGuestCPU (qemu_process.c:5870)
|
|
|
99cbc7 |
...
|
|
|
99cbc7 |
Address 0xf752d40 is 0 bytes after a block of size 0 alloc'd
|
|
|
99cbc7 |
at 0x4C30EC6: calloc (vg_replace_malloc.c:711)
|
|
|
99cbc7 |
by 0x5DBDE4E: virAllocN (viralloc.c:190)
|
|
|
99cbc7 |
by 0x5F3E4FA: x86ModelCopySignatures (cpu_x86.c:990)
|
|
|
99cbc7 |
by 0x5F3E60F: x86ModelCopy (cpu_x86.c:1008)
|
|
|
99cbc7 |
by 0x5F3E7CB: x86ModelFromCPU (cpu_x86.c:1068)
|
|
|
99cbc7 |
by 0x5F4397E: virCPUx86Translate (cpu_x86.c:2922)
|
|
|
99cbc7 |
by 0x5F3C239: virCPUTranslate (cpu.c:927)
|
|
|
99cbc7 |
by 0x57CE7A1: qemuProcessUpdateGuestCPU (qemu_process.c:5870)
|
|
|
99cbc7 |
...
|
|
|
99cbc7 |
|
|
|
99cbc7 |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
99cbc7 |
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
99cbc7 |
(cherry picked from commit 62cb9c335c43a722e81ac0a1ed6e1111ba1d428b)
|
|
|
99cbc7 |
|
|
|
99cbc7 |
https://bugzilla.redhat.com/show_bug.cgi?id=1558558
|
|
|
99cbc7 |
https://bugzilla.redhat.com/show_bug.cgi?id=1687515
|
|
|
99cbc7 |
|
|
|
99cbc7 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
99cbc7 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
99cbc7 |
---
|
|
|
99cbc7 |
src/cpu/cpu_x86.c | 3 +++
|
|
|
99cbc7 |
1 file changed, 3 insertions(+)
|
|
|
99cbc7 |
|
|
|
99cbc7 |
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
|
|
|
99cbc7 |
index f6844aaa0d..466c79031d 100644
|
|
|
99cbc7 |
--- a/src/cpu/cpu_x86.c
|
|
|
99cbc7 |
+++ b/src/cpu/cpu_x86.c
|
|
|
99cbc7 |
@@ -1021,6 +1021,9 @@ x86ModelCopySignatures(virCPUx86ModelPtr dst,
|
|
|
99cbc7 |
{
|
|
|
99cbc7 |
size_t i;
|
|
|
99cbc7 |
|
|
|
99cbc7 |
+ if (src->nsignatures == 0)
|
|
|
99cbc7 |
+ return 0;
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
if (VIR_ALLOC_N(dst->signatures, src->nsignatures) < 0)
|
|
|
99cbc7 |
return -1;
|
|
|
99cbc7 |
|
|
|
99cbc7 |
--
|
|
|
99cbc7 |
2.21.0
|
|
|
99cbc7 |
|