summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/recipes-devtools/qemu/qemu.inc1
-rw-r--r--meta/recipes-devtools/qemu/qemu/CVE-2020-14394.patch79
2 files changed, 80 insertions, 0 deletions
diff --git a/meta/recipes-devtools/qemu/qemu.inc b/meta/recipes-devtools/qemu/qemu.inc
index 96a1cc93a5..8182342f92 100644
--- a/meta/recipes-devtools/qemu/qemu.inc
+++ b/meta/recipes-devtools/qemu/qemu.inc
@@ -97,6 +97,7 @@ SRC_URI = "https://download.qemu.org/${BPN}-${PV}.tar.xz \
97 file://CVE-2023-3301.patch \ 97 file://CVE-2023-3301.patch \
98 file://CVE-2023-3255.patch \ 98 file://CVE-2023-3255.patch \
99 file://CVE-2023-2861.patch \ 99 file://CVE-2023-2861.patch \
100 file://CVE-2020-14394.patch \
100 " 101 "
101UPSTREAM_CHECK_REGEX = "qemu-(?P<pver>\d+(\.\d+)+)\.tar" 102UPSTREAM_CHECK_REGEX = "qemu-(?P<pver>\d+(\.\d+)+)\.tar"
102 103
diff --git a/meta/recipes-devtools/qemu/qemu/CVE-2020-14394.patch b/meta/recipes-devtools/qemu/qemu/CVE-2020-14394.patch
new file mode 100644
index 0000000000..aff91a7355
--- /dev/null
+++ b/meta/recipes-devtools/qemu/qemu/CVE-2020-14394.patch
@@ -0,0 +1,79 @@
1From effaf5a240e03020f4ae953e10b764622c3e87cc Mon Sep 17 00:00:00 2001
2From: Thomas Huth <thuth@redhat.com>
3Date: Tue, 8 Aug 2023 10:44:51 +0000
4Subject: [PATCH] hw/usb/hcd-xhci: Fix unbounded loop in
5 xhci_ring_chain_length() (CVE-2020-14394)
6
7The loop condition in xhci_ring_chain_length() is under control of
8the guest, and additionally the code does not check for failed DMA
9transfers (e.g. if reaching the end of the RAM), so the loop there
10could run for a very long time or even forever. Fix it by checking
11the return value of dma_memory_read() and by introducing a maximum
12loop length.
13
14Resolves: https://gitlab.com/qemu-project/qemu/-/issues/646
15Message-Id: <20220804131300.96368-1-thuth@redhat.com>
16Reviewed-by: Mauro Matteo Cascella <mcascell@redhat.com>
17Acked-by: Gerd Hoffmann <kraxel@redhat.com>
18Signed-off-by: Thomas Huth <thuth@redhat.com>
19
20CVE: CVE-2020-14394
21
22Upstream-Status: Backport [https://gitlab.com/qemu-project/qemu/-/commit/effaf5a240e03020f4ae953e10b764622c3e87cc]
23
24Signed-off-by: Yogita Urade <yogita.urade@windriver.com>
25---
26 hw/usb/hcd-xhci.c | 23 +++++++++++++++++++----
27 1 file changed, 19 insertions(+), 4 deletions(-)
28
29diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
30index 14bdb8967..c63a36dcc 100644
31--- a/hw/usb/hcd-xhci.c
32+++ b/hw/usb/hcd-xhci.c
33@@ -21,6 +21,7 @@
34
35 #include "qemu/osdep.h"
36 #include "qemu/timer.h"
37+#include "qemu/log.h"
38 #include "qemu/module.h"
39 #include "qemu/queue.h"
40 #include "migration/vmstate.h"
41@@ -725,10 +726,14 @@ static int xhci_ring_chain_length(XHCIState *xhci, const XHCIRing *ring)
42 bool control_td_set = 0;
43 uint32_t link_cnt = 0;
44
45- while (1) {
46+ do {
47 TRBType type;
48- dma_memory_read(xhci->as, dequeue, &trb, TRB_SIZE,
49- MEMTXATTRS_UNSPECIFIED);
50+ if (dma_memory_read(xhci->as, dequeue, &trb, TRB_SIZE,
51+ MEMTXATTRS_UNSPECIFIED) != MEMTX_OK) {
52+ qemu_log_mask(LOG_GUEST_ERROR, "%s: DMA memory access failed!\n",
53+ __func__);
54+ return -1;
55+ }
56 le64_to_cpus(&trb.parameter);
57 le32_to_cpus(&trb.status);
58 le32_to_cpus(&trb.control);
59@@ -762,7 +767,17 @@ static int xhci_ring_chain_length(XHCIState *xhci, const XHCIRing *ring)
60 if (!control_td_set && !(trb.control & TRB_TR_CH)) {
61 return length;
62 }
63- }
64+
65+ /*
66+ * According to the xHCI spec, Transfer Ring segments should have
67+ * a maximum size of 64 kB (see chapter "6 Data Structures")
68+ */
69+ } while (length < TRB_LINK_LIMIT * 65536 / TRB_SIZE);
70+
71+ qemu_log_mask(LOG_GUEST_ERROR, "%s: exceeded maximum tranfer ring size!\n",
72+ __func__);
73+
74+ return -1;
75 }
76
77 static void xhci_er_reset(XHCIState *xhci, int v)
78--
792.35.5