Browse code

libvirt : Fix CVE-2018-1064

Change-Id: I03d65a2604c95ab856a885c7dfd86694989da9fd
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/5049
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Sharath George

Xiaolin Li authored on 2018/04/21 03:34:35
Showing 2 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,59 @@
0
+From fbf31e1a4cd19d6f6e33e0937a009775cd7d9513 Mon Sep 17 00:00:00 2001
1
+From: =?utf8?q?Daniel=20P.=20Berrang=C3=A9?= <berrange@redhat.com>
2
+Date: Thu, 1 Mar 2018 14:55:26 +0000
3
+Subject: [PATCH] qemu: avoid denial of service reading from QEMU guest agent (CVE-2018-1064)
4
+MIME-Version: 1.0
5
+Content-Type: text/plain; charset=utf8
6
+Content-Transfer-Encoding: 8bit
7
+
8
+We read from the agent until seeing a \r\n pair to indicate a completed
9
+reply or event. To avoid memory denial-of-service though, we must have a
10
+size limit on amount of data we buffer. 10 MB is large enough that it
11
+ought to cope with normal agent replies, and small enough that we're not
12
+consuming unreasonable mem.
13
+
14
+This is identical to the flaw we had reading from the QEMU monitor
15
+as CVE-2018-5748, so rather embarrassing that we forgot to fix
16
+the agent code at the same time.
17
+
18
+Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
19
+---
20
+ src/qemu/qemu_agent.c |   15 +++++++++++++++
21
+ 1 files changed, 15 insertions(+), 0 deletions(-)
22
+
23
+diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
24
+index 0f36054..89183c3 100644
25
+--- a/src/qemu/qemu_agent.c
26
+@@ -53,6 +53,15 @@ VIR_LOG_INIT("qemu.qemu_agent");
27
+ #define DEBUG_IO 0
28
+ #define DEBUG_RAW_IO 0
29
+ 
30
++/* We read from QEMU until seeing a \r\n pair to indicate a
31
++ * completed reply or event. To avoid memory denial-of-service
32
++ * though, we must have a size limit on amount of data we
33
++ * buffer. 10 MB is large enough that it ought to cope with
34
++ * normal QEMU replies, and small enough that we're not
35
++ * consuming unreasonable mem.
36
++ */
37
++#define QEMU_AGENT_MAX_RESPONSE (10 * 1024 * 1024)
38
++
39
+ /* When you are the first to uncomment this,
40
+  * don't forget to uncomment the corresponding
41
+  * part in qemuAgentIOProcessEvent as well.
42
+@@ -535,6 +544,12 @@ qemuAgentIORead(qemuAgentPtr mon)
43
+     int ret = 0;
44
+ 
45
+     if (avail < 1024) {
46
++        if (mon->bufferLength >= QEMU_AGENT_MAX_RESPONSE) {
47
++            virReportSystemError(ERANGE,
48
++                                 _("No complete agent response found in %d bytes"),
49
++                                 QEMU_AGENT_MAX_RESPONSE);
50
++            return -1;
51
++        }
52
+         if (VIR_REALLOC_N(mon->buffer,
53
+                           mon->bufferLength + 1024) < 0)
54
+             return -1;
55
+-- 
56
+1.7.1
57
+
... ...
@@ -1,12 +1,13 @@
1 1
 Summary:        Virtualization API library that supports KVM, QEMU, Xen, ESX etc
2 2
 Name:           libvirt
3 3
 Version:        3.2.0
4
-Release:        4%{?dist}
4
+Release:        5%{?dist}
5 5
 License:        LGPL
6 6
 URL:            http://libvirt.org/
7 7
 Source0:        http://libvirt.org/sources/%{name}-%{version}.tar.xz
8 8
 %define sha1    libvirt=47d4b443fdf1e268589529018c436bbc4b413a7c
9 9
 Patch0:         libvirt-CVE-2017-1000256.patch
10
+Patch1:         libvirt-CVE-2018-1064.patch
10 11
 Group:          Virtualization/Libraries
11 12
 Vendor:         VMware, Inc.
12 13
 Distribution:   Photon
... ...
@@ -56,6 +57,7 @@ This contains development tools and libraries for libvirt.
56 56
 %prep
57 57
 %setup -q
58 58
 %patch0 -p1
59
+%patch1 -p1
59 60
 %build
60 61
 ./configure \
61 62
     --disable-silent-rules \
... ...
@@ -111,6 +113,8 @@ find %{buildroot} -name '*.la' -delete
111 111
 %{_mandir}/*
112 112
 
113 113
 %changelog
114
+*   Fri Apr 20 2018 Xiaolin Li <xiaolinl@vmware.com> 3.2.0-5
115
+-   Fix CVE-2018-1064
114 116
 *   Thu Dec 07 2017 Xiaolin Li <xiaolinl@vmware.com> 3.2.0-4
115 117
 -   Move so files in folder connection-driver and lock-driver to main package.
116 118
 *   Mon Dec 04 2017 Xiaolin Li <xiaolinl@vmware.com> 3.2.0-3