diff --git a/SOURCES/kvm-Fix-use-afte-free-in-ip_reass-CVE-2020-1983.patch b/SOURCES/kvm-Fix-use-afte-free-in-ip_reass-CVE-2020-1983.patch new file mode 100644 index 0000000..293aa41 --- /dev/null +++ b/SOURCES/kvm-Fix-use-afte-free-in-ip_reass-CVE-2020-1983.patch @@ -0,0 +1,73 @@ +From 06b7f03c663268ad662892c91925724f5ae9eb9b Mon Sep 17 00:00:00 2001 +From: Jon Maloy +Date: Sat, 20 Jun 2020 15:19:21 -0400 +Subject: [PATCH 2/2] Fix use-afte-free in ip_reass() (CVE-2020-1983) +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +RH-Author: Jon Maloy +Message-id: <20200620151921.3353831-2-jmaloy@redhat.com> +Patchwork-id: 97682 +O-Subject: [RHEL-7.9 qemu-kvm-ma PATCH 1/1] Fix use-afte-free in ip_reass() (CVE-2020-1983) +Bugzilla: 1837568 +RH-Acked-by: Thomas Huth +RH-Acked-by: Stefano Garzarella +RH-Acked-by: Stefan Hajnoczi + +From: Marc-André Lureau + +The q pointer is updated when the mbuf data is moved from m_dat to +m_ext. + +m_ext buffer may also be realloc()'ed and moved during m_cat(): +q should also be updated in this case. + +Reported-by: Aviv Sasson +Signed-off-by: Marc-André Lureau +Reviewed-by: Samuel Thibault + +(cherry picked from libslirp commit 9bd6c5913271eabcb7768a58197ed3301fe19f2d) +Conflicts: + - Fixed indentation issues +Signed-off-by: Jon Maloy +Signed-off-by: Jon Maloy +--- + slirp/ip_input.c | 9 ++++----- + 1 file changed, 4 insertions(+), 5 deletions(-) + +diff --git a/slirp/ip_input.c b/slirp/ip_input.c +index 7cf01336bf..9d2d79dfff 100644 +--- a/slirp/ip_input.c ++++ b/slirp/ip_input.c +@@ -333,10 +333,10 @@ insert: + /* + * Reassembly is complete; concatenate fragments. + */ +- q = fp->frag_link.next; ++ q = fp->frag_link.next; + m = dtom(slirp, q); + +- int was_ext = m->m_flags & M_EXT; ++ int delta = (char *)q - (m->m_flags & M_EXT ? m->m_ext : m->m_dat); + + q = (struct ipasfrag *) q->ipf_next; + while (q != (struct ipasfrag*)&fp->frag_link) { +@@ -360,12 +360,11 @@ insert: + * the old buffer (in the mbuf), so we must point ip + * into the new buffer. + */ +- if (!was_ext && m->m_flags & M_EXT) { +- int delta = (char *)q - m->m_dat; ++ if (m->m_flags & M_EXT) { + q = (struct ipasfrag *)(m->m_ext + delta); + } + +- ip = fragtoip(q); ++ ip = fragtoip(q); + ip->ip_len = next; + ip->ip_tos &= ~1; + ip->ip_src = fp->ipq_src; +-- +2.18.2 + diff --git a/SOURCES/kvm-usb-fix-setup_len-init-CVE-2020-14364.patch b/SOURCES/kvm-usb-fix-setup_len-init-CVE-2020-14364.patch new file mode 100644 index 0000000..563b082 --- /dev/null +++ b/SOURCES/kvm-usb-fix-setup_len-init-CVE-2020-14364.patch @@ -0,0 +1,102 @@ +From 073700e59f942e2fcc8c97b87705af03056e8032 Mon Sep 17 00:00:00 2001 +From: Jon Maloy +Date: Fri, 4 Sep 2020 15:51:11 -0400 +Subject: [PATCH 1/2] usb: fix setup_len init (CVE-2020-14364) + +RH-Author: Jon Maloy +Message-id: <20200904155111.69297-2-jmaloy@redhat.com> +Patchwork-id: 98288 +O-Subject: [RHEL-7.9.z qemu-kvm-rhev PATCH 1/1] usb: fix setup_len init (CVE-2020-14364) +Bugzilla: 1869706 +RH-Acked-by: Dr. David Alan Gilbert +RH-Acked-by: Gerd Hoffmann +RH-Acked-by: Thomas Huth + +From: Gerd Hoffmann + +Store calculated setup_len in a local variable, verify it, and only +write it to the struct (USBDevice->setup_len) in case it passed the +sanity checks. + +This prevents other code (do_token_{in,out} functions specifically) +from working with invalid USBDevice->setup_len values and overrunning +the USBDevice->setup_buf[] buffer. + +Fixes: CVE-2020-14364 +Signed-off-by: Gerd Hoffmann +Tested-by: Gonglei +Reviewed-by: Li Qiang +Message-id: 20200825053636.29648-1-kraxel@redhat.com +(cherry picked from commit b946434f2659a182afc17e155be6791ebfb302eb) +Signed-off-by: Jon Maloy +Signed-off-by: Jon Maloy +--- + hw/usb/core.c | 16 ++++++++++------ + 1 file changed, 10 insertions(+), 6 deletions(-) + +diff --git a/hw/usb/core.c b/hw/usb/core.c +index 07b67fbbd7..e816eded2d 100644 +--- a/hw/usb/core.c ++++ b/hw/usb/core.c +@@ -130,6 +130,7 @@ void usb_wakeup(USBEndpoint *ep, unsigned int stream) + static void do_token_setup(USBDevice *s, USBPacket *p) + { + int request, value, index; ++ unsigned int setup_len; + + if (p->iov.size != 8) { + p->status = USB_RET_STALL; +@@ -139,14 +140,15 @@ static void do_token_setup(USBDevice *s, USBPacket *p) + usb_packet_copy(p, s->setup_buf, p->iov.size); + s->setup_index = 0; + p->actual_length = 0; +- s->setup_len = (s->setup_buf[7] << 8) | s->setup_buf[6]; +- if (s->setup_len > sizeof(s->data_buf)) { ++ setup_len = (s->setup_buf[7] << 8) | s->setup_buf[6]; ++ if (setup_len > sizeof(s->data_buf)) { + fprintf(stderr, + "usb_generic_handle_packet: ctrl buffer too small (%d > %zu)\n", +- s->setup_len, sizeof(s->data_buf)); ++ setup_len, sizeof(s->data_buf)); + p->status = USB_RET_STALL; + return; + } ++ s->setup_len = setup_len; + + request = (s->setup_buf[0] << 8) | s->setup_buf[1]; + value = (s->setup_buf[3] << 8) | s->setup_buf[2]; +@@ -260,26 +262,28 @@ static void do_token_out(USBDevice *s, USBPacket *p) + static void do_parameter(USBDevice *s, USBPacket *p) + { + int i, request, value, index; ++ unsigned int setup_len; + + for (i = 0; i < 8; i++) { + s->setup_buf[i] = p->parameter >> (i*8); + } + + s->setup_state = SETUP_STATE_PARAM; +- s->setup_len = (s->setup_buf[7] << 8) | s->setup_buf[6]; + s->setup_index = 0; + + request = (s->setup_buf[0] << 8) | s->setup_buf[1]; + value = (s->setup_buf[3] << 8) | s->setup_buf[2]; + index = (s->setup_buf[5] << 8) | s->setup_buf[4]; + +- if (s->setup_len > sizeof(s->data_buf)) { ++ setup_len = (s->setup_buf[7] << 8) | s->setup_buf[6]; ++ if (setup_len > sizeof(s->data_buf)) { + fprintf(stderr, + "usb_generic_handle_packet: ctrl buffer too small (%d > %zu)\n", +- s->setup_len, sizeof(s->data_buf)); ++ setup_len, sizeof(s->data_buf)); + p->status = USB_RET_STALL; + return; + } ++ s->setup_len = setup_len; + + if (p->pid == USB_TOKEN_OUT) { + usb_packet_copy(p, s->data_buf, s->setup_len); +-- +2.18.2 + diff --git a/SPECS/qemu-kvm.spec b/SPECS/qemu-kvm.spec index c584a93..c4e5bf5 100644 --- a/SPECS/qemu-kvm.spec +++ b/SPECS/qemu-kvm.spec @@ -108,7 +108,7 @@ Obsoletes: %1%{rhel_ma_suffix} < %{obsoletes_version2} \ Summary: QEMU is a machine emulator and virtualizer Name: %{pkgname}%{?pkgsuffix} Version: 2.12.0 -Release: 48%{?dist} +Release: 48%{?dist}.1 # Epoch because we pushed a qemu-1.0 package. AIUI this can't ever be dropped Epoch: 10 License: GPLv2 and GPLv2+ and CC-BY @@ -1992,6 +1992,10 @@ Patch914: kvm-file-posix-Use-max-transfer-length-segment-count-onl.patch Patch915: kvm-vnc-add-magic-cookie-to-VncState.patch # For bz#1810409 - CVE-2019-20382 qemu-kvm-rhev: QEMU: vnc: memory leakage upon disconnect [rhel-7] Patch916: kvm-vnc-fix-memory-leak-when-vnc-disconnect.patch +# For bz#1869706 - CVE-2020-14364 qemu-kvm-ma: QEMU: usb: out-of-bounds r/w access issue while processing usb packets [rhel-7.9.z] +Patch917: kvm-usb-fix-setup_len-init-CVE-2020-14364.patch +# For bz#1837568 - CVE-2020-1983 qemu-kvm-ma: QEMU: slirp: use-after-free in ip_reass() function in ip_input.c [rhel-7] +Patch918: kvm-Fix-use-afte-free-in-ip_reass-CVE-2020-1983.patch BuildRequires: zlib-devel BuildRequires: glib2-devel @@ -3125,6 +3129,8 @@ ApplyOptionalPatch() %patch914 -p1 %patch915 -p1 %patch916 -p1 +%patch917 -p1 +%patch918 -p1 # Fix executable permission for iotests chmod 755 $(ls tests/qemu-iotests/???) @@ -3645,6 +3651,11 @@ useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin \ %endif %changelog +* Mon Sep 14 2020 Jon Maloy - ma-2.12.0-48.el7_9.1 +- kvm-usb-fix-setup_len-init-CVE-2020-14364.patch [bz#1869706] +- Resolves: bz#1869706 + (CVE-2020-14364 qemu-kvm-ma: QEMU: usb: out-of-bounds r/w access issue while processing usb packets [rhel-7.9.z]) + * Thu May 28 2020 Miroslav Rezanina - 2.12.0-48.el7 - kvm-vnc-add-magic-cookie-to-VncState.patch [bz#1810409] - kvm-vnc-fix-memory-leak-when-vnc-disconnect.patch [bz#1810409]