diff options
| author | Ross Burton <ross@burtonini.com> | 2020-09-10 22:04:10 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-09-12 14:49:00 +0100 |
| commit | e2ab24ce35794112b32cafd8197416ea932fe2a4 (patch) | |
| tree | 41126e8e58011d6728003a87ce151cd5184692f1 | |
| parent | 72748e1c3d2d63ae25c15b6cdfde7e0b747c1dfa (diff) | |
| download | poky-e2ab24ce35794112b32cafd8197416ea932fe2a4.tar.gz | |
qemu: fix CVE-2020-14364
Backport a patch from upstream to fix CVE-2020-14364.
(From OE-Core rev: 1ffd4d94e879b338e190a2c4798a4e0bada9b5a7)
Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | meta/recipes-devtools/qemu/qemu.inc | 7 | ||||
| -rw-r--r-- | meta/recipes-devtools/qemu/qemu/usb-fix-setup_len-init.patch | 89 |
2 files changed, 93 insertions, 3 deletions
diff --git a/meta/recipes-devtools/qemu/qemu.inc b/meta/recipes-devtools/qemu/qemu.inc index 5599382a92..9091115caf 100644 --- a/meta/recipes-devtools/qemu/qemu.inc +++ b/meta/recipes-devtools/qemu/qemu.inc | |||
| @@ -28,9 +28,10 @@ SRC_URI = "https://download.qemu.org/${BPN}-${PV}.tar.xz \ | |||
| 28 | file://0009-Fix-webkitgtk-builds.patch \ | 28 | file://0009-Fix-webkitgtk-builds.patch \ |
| 29 | file://0010-configure-Add-pkg-config-handling-for-libgcrypt.patch \ | 29 | file://0010-configure-Add-pkg-config-handling-for-libgcrypt.patch \ |
| 30 | file://0001-Add-enable-disable-udev.patch \ | 30 | file://0001-Add-enable-disable-udev.patch \ |
| 31 | file://0001-qemu-Do-not-include-file-if-not-exists.patch \ | 31 | file://0001-qemu-Do-not-include-file-if-not-exists.patch \ |
| 32 | file://find_datadir.patch \ | 32 | file://find_datadir.patch \ |
| 33 | " | 33 | file://usb-fix-setup_len-init.patch \ |
| 34 | " | ||
| 34 | UPSTREAM_CHECK_REGEX = "qemu-(?P<pver>\d+(\.\d+)+)\.tar" | 35 | UPSTREAM_CHECK_REGEX = "qemu-(?P<pver>\d+(\.\d+)+)\.tar" |
| 35 | 36 | ||
| 36 | SRC_URI[sha256sum] = "c9174eb5933d9eb5e61f541cd6d1184cd3118dfe4c5c4955bc1bdc4d390fa4e5" | 37 | SRC_URI[sha256sum] = "c9174eb5933d9eb5e61f541cd6d1184cd3118dfe4c5c4955bc1bdc4d390fa4e5" |
diff --git a/meta/recipes-devtools/qemu/qemu/usb-fix-setup_len-init.patch b/meta/recipes-devtools/qemu/qemu/usb-fix-setup_len-init.patch new file mode 100644 index 0000000000..92801da46f --- /dev/null +++ b/meta/recipes-devtools/qemu/qemu/usb-fix-setup_len-init.patch | |||
| @@ -0,0 +1,89 @@ | |||
| 1 | CVE: CVE-2020-14364 | ||
| 2 | Upstream-Status: Backport | ||
| 3 | Signed-off-by: Ross Burton <ross.burton@arm.com> | ||
| 4 | |||
| 5 | From b946434f2659a182afc17e155be6791ebfb302eb Mon Sep 17 00:00:00 2001 | ||
| 6 | From: Gerd Hoffmann <kraxel@redhat.com> | ||
| 7 | Date: Tue, 25 Aug 2020 07:36:36 +0200 | ||
| 8 | Subject: [PATCH] usb: fix setup_len init (CVE-2020-14364) | ||
| 9 | |||
| 10 | Store calculated setup_len in a local variable, verify it, and only | ||
| 11 | write it to the struct (USBDevice->setup_len) in case it passed the | ||
| 12 | sanity checks. | ||
| 13 | |||
| 14 | This prevents other code (do_token_{in,out} functions specifically) | ||
| 15 | from working with invalid USBDevice->setup_len values and overrunning | ||
| 16 | the USBDevice->setup_buf[] buffer. | ||
| 17 | |||
| 18 | Fixes: CVE-2020-14364 | ||
| 19 | Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> | ||
| 20 | Tested-by: Gonglei <arei.gonglei@huawei.com> | ||
| 21 | Reviewed-by: Li Qiang <liq3ea@gmail.com> | ||
| 22 | Message-id: 20200825053636.29648-1-kraxel@redhat.com | ||
| 23 | --- | ||
| 24 | hw/usb/core.c | 16 ++++++++++------ | ||
| 25 | 1 file changed, 10 insertions(+), 6 deletions(-) | ||
| 26 | |||
| 27 | diff --git a/hw/usb/core.c b/hw/usb/core.c | ||
| 28 | index 5abd128b6bc..5234dcc73fe 100644 | ||
| 29 | --- a/hw/usb/core.c | ||
| 30 | +++ b/hw/usb/core.c | ||
| 31 | @@ -129,6 +129,7 @@ void usb_wakeup(USBEndpoint *ep, unsigned int stream) | ||
| 32 | static void do_token_setup(USBDevice *s, USBPacket *p) | ||
| 33 | { | ||
| 34 | int request, value, index; | ||
| 35 | + unsigned int setup_len; | ||
| 36 | |||
| 37 | if (p->iov.size != 8) { | ||
| 38 | p->status = USB_RET_STALL; | ||
| 39 | @@ -138,14 +139,15 @@ static void do_token_setup(USBDevice *s, USBPacket *p) | ||
| 40 | usb_packet_copy(p, s->setup_buf, p->iov.size); | ||
| 41 | s->setup_index = 0; | ||
| 42 | p->actual_length = 0; | ||
| 43 | - s->setup_len = (s->setup_buf[7] << 8) | s->setup_buf[6]; | ||
| 44 | - if (s->setup_len > sizeof(s->data_buf)) { | ||
| 45 | + setup_len = (s->setup_buf[7] << 8) | s->setup_buf[6]; | ||
| 46 | + if (setup_len > sizeof(s->data_buf)) { | ||
| 47 | fprintf(stderr, | ||
| 48 | "usb_generic_handle_packet: ctrl buffer too small (%d > %zu)\n", | ||
| 49 | - s->setup_len, sizeof(s->data_buf)); | ||
| 50 | + setup_len, sizeof(s->data_buf)); | ||
| 51 | p->status = USB_RET_STALL; | ||
| 52 | return; | ||
| 53 | } | ||
| 54 | + s->setup_len = setup_len; | ||
| 55 | |||
| 56 | request = (s->setup_buf[0] << 8) | s->setup_buf[1]; | ||
| 57 | value = (s->setup_buf[3] << 8) | s->setup_buf[2]; | ||
| 58 | @@ -259,26 +261,28 @@ static void do_token_out(USBDevice *s, USBPacket *p) | ||
| 59 | static void do_parameter(USBDevice *s, USBPacket *p) | ||
| 60 | { | ||
| 61 | int i, request, value, index; | ||
| 62 | + unsigned int setup_len; | ||
| 63 | |||
| 64 | for (i = 0; i < 8; i++) { | ||
| 65 | s->setup_buf[i] = p->parameter >> (i*8); | ||
| 66 | } | ||
| 67 | |||
| 68 | s->setup_state = SETUP_STATE_PARAM; | ||
| 69 | - s->setup_len = (s->setup_buf[7] << 8) | s->setup_buf[6]; | ||
| 70 | s->setup_index = 0; | ||
| 71 | |||
| 72 | request = (s->setup_buf[0] << 8) | s->setup_buf[1]; | ||
| 73 | value = (s->setup_buf[3] << 8) | s->setup_buf[2]; | ||
| 74 | index = (s->setup_buf[5] << 8) | s->setup_buf[4]; | ||
| 75 | |||
| 76 | - if (s->setup_len > sizeof(s->data_buf)) { | ||
| 77 | + setup_len = (s->setup_buf[7] << 8) | s->setup_buf[6]; | ||
| 78 | + if (setup_len > sizeof(s->data_buf)) { | ||
| 79 | fprintf(stderr, | ||
| 80 | "usb_generic_handle_packet: ctrl buffer too small (%d > %zu)\n", | ||
| 81 | - s->setup_len, sizeof(s->data_buf)); | ||
| 82 | + setup_len, sizeof(s->data_buf)); | ||
| 83 | p->status = USB_RET_STALL; | ||
| 84 | return; | ||
| 85 | } | ||
| 86 | + s->setup_len = setup_len; | ||
| 87 | |||
| 88 | if (p->pid == USB_TOKEN_OUT) { | ||
| 89 | usb_packet_copy(p, s->data_buf, s->setup_len); | ||
