|
|
7711c0 |
From 16f855a65838c81a35ac65a8a8b1084fa0b39689 Mon Sep 17 00:00:00 2001
|
|
|
7711c0 |
From: David Hildenbrand <david@redhat.com>
|
|
|
7711c0 |
Date: Fri, 21 Sep 2018 09:43:58 +0200
|
|
|
7711c0 |
Subject: [PATCH 04/22] exec: check that alignment is a power of two
|
|
|
7711c0 |
|
|
|
7711c0 |
RH-Author: David Hildenbrand <david@redhat.com>
|
|
|
7711c0 |
Message-id: <20180921094358.12256-1-david@redhat.com>
|
|
|
7711c0 |
Patchwork-id: 82228
|
|
|
7711c0 |
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH] exec: check that alignment is a power of two
|
|
|
7711c0 |
Bugzilla: 1629717
|
|
|
7711c0 |
RH-Acked-by: Pankaj Gupta <pagupta@redhat.com>
|
|
|
7711c0 |
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
7711c0 |
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
|
|
|
7711c0 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
7711c0 |
|
|
|
7711c0 |
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1629717
|
|
|
7711c0 |
Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=18439720
|
|
|
7711c0 |
Upstream: 61362b71c105ccb151ca16897a7d56534423f390
|
|
|
7711c0 |
|
|
|
7711c0 |
Right now we can crash QEMU using e.g.
|
|
|
7711c0 |
|
|
|
7711c0 |
qemu-system-x86_64 -m 256M,maxmem=20G,slots=2 \
|
|
|
7711c0 |
-object memory-backend-file,id=mem0,size=12288,mem-path=/dev/zero,align=12288 \
|
|
|
7711c0 |
-device pc-dimm,id=dimm1,memdev=mem0
|
|
|
7711c0 |
|
|
|
7711c0 |
qemu-system-x86_64: util/mmap-alloc.c:115:
|
|
|
7711c0 |
qemu_ram_mmap: Assertion `is_power_of_2(align)' failed
|
|
|
7711c0 |
|
|
|
7711c0 |
Fix this by adding a proper check.
|
|
|
7711c0 |
|
|
|
7711c0 |
Signed-off-by: David Hildenbrand <david@redhat.com>
|
|
|
7711c0 |
Message-Id: <20180607154705.6316-3-david@redhat.com>
|
|
|
7711c0 |
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
7711c0 |
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
|
|
|
7711c0 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
7711c0 |
(cherry picked from commit 61362b71c105ccb151ca16897a7d56534423f390)
|
|
|
7711c0 |
Signed-off-by: David Hildenbrand <david@redhat.com>
|
|
|
7711c0 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
7711c0 |
---
|
|
|
7711c0 |
exec.c | 4 ++++
|
|
|
7711c0 |
1 file changed, 4 insertions(+)
|
|
|
7711c0 |
|
|
|
7711c0 |
diff --git a/exec.c b/exec.c
|
|
|
7711c0 |
index c670185..9028700 100644
|
|
|
7711c0 |
--- a/exec.c
|
|
|
7711c0 |
+++ b/exec.c
|
|
|
7711c0 |
@@ -1629,6 +1629,10 @@ static void *file_ram_alloc(RAMBlock *block,
|
|
|
7711c0 |
" must be multiples of page size 0x%zx",
|
|
|
7711c0 |
block->mr->align, block->page_size);
|
|
|
7711c0 |
return NULL;
|
|
|
7711c0 |
+ } else if (block->mr->align && !is_power_of_2(block->mr->align)) {
|
|
|
7711c0 |
+ error_setg(errp, "alignment 0x%" PRIx64
|
|
|
7711c0 |
+ " must be a power of two", block->mr->align);
|
|
|
7711c0 |
+ return NULL;
|
|
|
7711c0 |
}
|
|
|
7711c0 |
block->mr->align = MAX(block->page_size, block->mr->align);
|
|
|
7711c0 |
#if defined(__s390x__)
|
|
|
7711c0 |
--
|
|
|
7711c0 |
1.8.3.1
|
|
|
7711c0 |
|