|
Pablo Greco |
40546a |
From e75abae126f9fcaf1e8478f0780ecae736f7d3e1 Mon Sep 17 00:00:00 2001
|
|
Pablo Greco |
40546a |
Message-Id: <e75abae126f9fcaf1e8478f0780ecae736f7d3e1@dist-git>
|
|
Pablo Greco |
40546a |
From: "Allen, John" <John.Allen@amd.com>
|
|
Pablo Greco |
40546a |
Date: Tue, 2 Jul 2019 17:05:34 +0200
|
|
Pablo Greco |
40546a |
Subject: [PATCH] Handle copying bitmaps to larger data buffers
|
|
Pablo Greco |
40546a |
MIME-Version: 1.0
|
|
Pablo Greco |
40546a |
Content-Type: text/plain; charset=UTF-8
|
|
Pablo Greco |
40546a |
Content-Transfer-Encoding: 8bit
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
If a bitmap of a shorter length than the data buffer is passed to
|
|
Pablo Greco |
40546a |
virBitmapToDataBuf, it will read off the end of the bitmap and copy junk
|
|
Pablo Greco |
40546a |
into the returned buffer. Add a check to only copy the length of the
|
|
Pablo Greco |
40546a |
bitmap to the buffer.
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
The problem can be observed after setting a vcpu affinity using the vcpupin
|
|
Pablo Greco |
40546a |
command on a system with a large number of cores:
|
|
Pablo Greco |
40546a |
# virsh vcpupin example_domain 0 0
|
|
Pablo Greco |
40546a |
# virsh vcpupin example_domain 0
|
|
Pablo Greco |
40546a |
VCPU CPU Affinity
|
|
Pablo Greco |
40546a |
---------------------------
|
|
Pablo Greco |
40546a |
0 0,192,197-198,202
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
Signed-off-by: John Allen <john.allen@amd.com>
|
|
Pablo Greco |
40546a |
(cherry picked from commit 51f9f80d350e633adf479c6a9b3c55f82ca9cbd4)
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
https: //bugzilla.redhat.com/show_bug.cgi?id=1703160
|
|
Pablo Greco |
40546a |
Signed-off-by: Erik Skultety <eskultet@redhat.com>
|
|
Pablo Greco |
40546a |
Message-Id: <1a487c4f1ba9725eb7325debeeff2861d7047890.1562079635.git.eskultet@redhat.com>
|
|
Pablo Greco |
40546a |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
Pablo Greco |
40546a |
---
|
|
Pablo Greco |
40546a |
src/util/virbitmap.c | 4 ++++
|
|
Pablo Greco |
40546a |
1 file changed, 4 insertions(+)
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
|
|
Pablo Greco |
40546a |
index 49e542a4e6..7df0a2d4f3 100644
|
|
Pablo Greco |
40546a |
--- a/src/util/virbitmap.c
|
|
Pablo Greco |
40546a |
+++ b/src/util/virbitmap.c
|
|
Pablo Greco |
40546a |
@@ -831,11 +831,15 @@ virBitmapToDataBuf(virBitmapPtr bitmap,
|
|
Pablo Greco |
40546a |
unsigned char *bytes,
|
|
Pablo Greco |
40546a |
size_t len)
|
|
Pablo Greco |
40546a |
{
|
|
Pablo Greco |
40546a |
+ size_t nbytes = bitmap->map_len * (VIR_BITMAP_BITS_PER_UNIT / CHAR_BIT);
|
|
Pablo Greco |
40546a |
unsigned long *l;
|
|
Pablo Greco |
40546a |
size_t i, j;
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
memset(bytes, 0, len);
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
+ /* If bitmap and buffer differ in size, only fill to the smaller length */
|
|
Pablo Greco |
40546a |
+ len = MIN(len, nbytes);
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
/* htole64 is not provided by gnulib, so we do the conversion by hand */
|
|
Pablo Greco |
40546a |
l = bitmap->map;
|
|
Pablo Greco |
40546a |
for (i = j = 0; i < len; i++, j++) {
|
|
Pablo Greco |
40546a |
--
|
|
Pablo Greco |
40546a |
2.22.0
|
|
Pablo Greco |
40546a |
|