diff options
| author | Bhabu Bindu <bindudaniel1996@gmail.com> | 2023-01-09 15:05:18 +0530 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-01-26 23:37:05 +0000 |
| commit | da271d70f0491f81f567874282c8b57275171436 (patch) | |
| tree | e1f785399c045f5f9e4ce3e7db37c097fb7b4411 | |
| parent | d95be1c7edc3ce0b7a27c9d8dfbaa178162a89e9 (diff) | |
| download | poky-da271d70f0491f81f567874282c8b57275171436.tar.gz | |
qemu: Fix CVE-2022-4144
Add patch to fix CVE-2022-4144
Link: https://security-tracker.debian.org/tracker/CVE-2022-4144
(From OE-Core rev: 4cb3874abf4fdeb04337a48a14c765ba9b2269d4)
Signed-off-by: Bhabu Bindu <bhabu.bindu@kpit.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | meta/recipes-devtools/qemu/qemu.inc | 1 | ||||
| -rw-r--r-- | meta/recipes-devtools/qemu/qemu/CVE-2022-4144.patch | 99 |
2 files changed, 100 insertions, 0 deletions
diff --git a/meta/recipes-devtools/qemu/qemu.inc b/meta/recipes-devtools/qemu/qemu.inc index cc9681fb4b..b68be447f1 100644 --- a/meta/recipes-devtools/qemu/qemu.inc +++ b/meta/recipes-devtools/qemu/qemu.inc | |||
| @@ -92,6 +92,7 @@ SRC_URI = "https://download.qemu.org/${BPN}-${PV}.tar.xz \ | |||
| 92 | file://0020-target-ppc-move-xs-n-madd-am-ds-p-xs-n-msub-am-ds-p-.patch \ | 92 | file://0020-target-ppc-move-xs-n-madd-am-ds-p-xs-n-msub-am-ds-p-.patch \ |
| 93 | file://0021-target-ppc-implement-xs-n-maddqp-o-xs-n-msubqp-o.patch \ | 93 | file://0021-target-ppc-implement-xs-n-maddqp-o-xs-n-msubqp-o.patch \ |
| 94 | file://CVE-2022-3165.patch \ | 94 | file://CVE-2022-3165.patch \ |
| 95 | file://CVE-2022-4144.patch \ | ||
| 95 | " | 96 | " |
| 96 | UPSTREAM_CHECK_REGEX = "qemu-(?P<pver>\d+(\.\d+)+)\.tar" | 97 | UPSTREAM_CHECK_REGEX = "qemu-(?P<pver>\d+(\.\d+)+)\.tar" |
| 97 | 98 | ||
diff --git a/meta/recipes-devtools/qemu/qemu/CVE-2022-4144.patch b/meta/recipes-devtools/qemu/qemu/CVE-2022-4144.patch new file mode 100644 index 0000000000..96052a19e8 --- /dev/null +++ b/meta/recipes-devtools/qemu/qemu/CVE-2022-4144.patch | |||
| @@ -0,0 +1,99 @@ | |||
| 1 | From 6dbbf055148c6f1b7d8a3251a65bd6f3d1e1f622 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= <philmd@linaro.org> | ||
| 3 | Date: Mon, 28 Nov 2022 21:27:40 +0100 | ||
| 4 | Subject: [PATCH] hw/display/qxl: Avoid buffer overrun in qxl_phys2virt | ||
| 5 | (CVE-2022-4144) | ||
| 6 | MIME-Version: 1.0 | ||
| 7 | Content-Type: text/plain; charset=UTF-8 | ||
| 8 | Content-Transfer-Encoding: 8bit | ||
| 9 | |||
| 10 | Have qxl_get_check_slot_offset() return false if the requested | ||
| 11 | buffer size does not fit within the slot memory region. | ||
| 12 | |||
| 13 | Similarly qxl_phys2virt() now returns NULL in such case, and | ||
| 14 | qxl_dirty_one_surface() aborts. | ||
| 15 | |||
| 16 | This avoids buffer overrun in the host pointer returned by | ||
| 17 | memory_region_get_ram_ptr(). | ||
| 18 | |||
| 19 | Fixes: CVE-2022-4144 (out-of-bounds read) | ||
| 20 | Reported-by: Wenxu Yin (@awxylitol) | ||
| 21 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1336 | ||
| 22 | |||
| 23 | CVE: CVE-2022-4144 | ||
| 24 | Upstream-Status: Backport [https://gitlab.com/qemu-project/qemu/-/commit/6dbbf055148c6f1b7d8a3251a65bd6f3d1e1f622] | ||
| 25 | Comments: Deleted patch hunk in qxl.h,as it contains change | ||
| 26 | in comments which is not present in current version of qemu | ||
| 27 | |||
| 28 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
| 29 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
| 30 | Message-Id: <20221128202741.4945-5-philmd@linaro.org> | ||
| 31 | Signed-off-by: Bhabu Bindu <bhabu.bindu@kpit.com> | ||
| 32 | --- | ||
| 33 | hw/display/qxl.c | 27 +++++++++++++++++++++++---- | ||
| 34 | 1 files changed, 23 insertions(+), 4 deletions(-) | ||
| 35 | |||
| 36 | diff --git a/hw/display/qxl.c b/hw/display/qxl.c | ||
| 37 | index 231d733250..0b21626aad 100644 | ||
| 38 | --- a/hw/display/qxl.c | ||
| 39 | +++ b/hw/display/qxl.c | ||
| 40 | @@ -1424,11 +1424,13 @@ static void qxl_reset_surfaces(PCIQXLDevice *d) | ||
| 41 | |||
| 42 | /* can be also called from spice server thread context */ | ||
| 43 | static bool qxl_get_check_slot_offset(PCIQXLDevice *qxl, QXLPHYSICAL pqxl, | ||
| 44 | - uint32_t *s, uint64_t *o) | ||
| 45 | + uint32_t *s, uint64_t *o, | ||
| 46 | + size_t size_requested) | ||
| 47 | { | ||
| 48 | uint64_t phys = le64_to_cpu(pqxl); | ||
| 49 | uint32_t slot = (phys >> (64 - 8)) & 0xff; | ||
| 50 | uint64_t offset = phys & 0xffffffffffff; | ||
| 51 | + uint64_t size_available; | ||
| 52 | |||
| 53 | if (slot >= NUM_MEMSLOTS) { | ||
| 54 | qxl_set_guest_bug(qxl, "slot too large %d >= %d", slot, | ||
| 55 | @@ -1452,6 +1454,23 @@ static bool qxl_get_check_slot_offset(PCIQXLDevice *qxl, QXLPHYSICAL pqxl, | ||
| 56 | slot, offset, qxl->guest_slots[slot].size); | ||
| 57 | return false; | ||
| 58 | } | ||
| 59 | + size_available = memory_region_size(qxl->guest_slots[slot].mr); | ||
| 60 | + if (qxl->guest_slots[slot].offset + offset >= size_available) { | ||
| 61 | + qxl_set_guest_bug(qxl, | ||
| 62 | + "slot %d offset %"PRIu64" > region size %"PRIu64"\n", | ||
| 63 | + slot, qxl->guest_slots[slot].offset + offset, | ||
| 64 | + size_available); | ||
| 65 | + return false; | ||
| 66 | + } | ||
| 67 | + size_available -= qxl->guest_slots[slot].offset + offset; | ||
| 68 | + if (size_requested > size_available) { | ||
| 69 | + qxl_set_guest_bug(qxl, | ||
| 70 | + "slot %d offset %"PRIu64" size %zu: " | ||
| 71 | + "overrun by %"PRIu64" bytes\n", | ||
| 72 | + slot, offset, size_requested, | ||
| 73 | + size_requested - size_available); | ||
| 74 | + return false; | ||
| 75 | + } | ||
| 76 | |||
| 77 | *s = slot; | ||
| 78 | *o = offset; | ||
| 79 | @@ -1471,7 +1490,7 @@ void *qxl_phys2virt(PCIQXLDevice *qxl, QXLPHYSICAL pqxl, int group_id, | ||
| 80 | offset = le64_to_cpu(pqxl) & 0xffffffffffff; | ||
| 81 | return (void *)(intptr_t)offset; | ||
| 82 | case MEMSLOT_GROUP_GUEST: | ||
| 83 | - if (!qxl_get_check_slot_offset(qxl, pqxl, &slot, &offset)) { | ||
| 84 | + if (!qxl_get_check_slot_offset(qxl, pqxl, &slot, &offset, size)) { | ||
| 85 | return NULL; | ||
| 86 | } | ||
| 87 | ptr = memory_region_get_ram_ptr(qxl->guest_slots[slot].mr); | ||
| 88 | @@ -1937,9 +1956,9 @@ static void qxl_dirty_one_surface(PCIQXLDevice *qxl, QXLPHYSICAL pqxl, | ||
| 89 | uint32_t slot; | ||
| 90 | bool rc; | ||
| 91 | |||
| 92 | - rc = qxl_get_check_slot_offset(qxl, pqxl, &slot, &offset); | ||
| 93 | - assert(rc == true); | ||
| 94 | size = (uint64_t)height * abs(stride); | ||
| 95 | + rc = qxl_get_check_slot_offset(qxl, pqxl, &slot, &offset, size); | ||
| 96 | + assert(rc == true); | ||
| 97 | trace_qxl_surfaces_dirty(qxl->id, offset, size); | ||
| 98 | qxl_set_dirty(qxl->guest_slots[slot].mr, | ||
| 99 | qxl->guest_slots[slot].offset + offset, | ||
