mirror of
https://git.yoctoproject.org/poky
synced 2026-06-03 01:40:07 +00:00
qemu: CVE-2020-27821 heap buffer overflow in msix_table_mmio_write
Source: https://git.qemu.org/?p=qemu.git; MR: 107558 Type: Security Fix Disposition: Backport from https://git.qemu.org/?p=qemu.git;a=commit;h=4bfb024bc76973d40a359476dc0291f46e435442 ChangeID: c5d25422f43edb7d8728118eb482eba09474ef2c Description: CVE-2020-27821 qemu: heap buffer overflow in msix_table_mmio_write() in hw/pci/msix.c. (From OE-Core rev: 198bd53bdc77d2b01dae19993bde79f03f4dd02c) Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com> Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
5b956ef359
commit
cfd2eaa0e1
@@ -99,6 +99,7 @@ SRC_URI = "https://download.qemu.org/${BPN}-${PV}.tar.xz \
|
|||||||
file://CVE-2020-13253_5.patch \
|
file://CVE-2020-13253_5.patch \
|
||||||
file://CVE-2020-13791.patch \
|
file://CVE-2020-13791.patch \
|
||||||
file://CVE-2022-35414.patch \
|
file://CVE-2022-35414.patch \
|
||||||
|
file://CVE-2020-27821.patch \
|
||||||
"
|
"
|
||||||
UPSTREAM_CHECK_REGEX = "qemu-(?P<pver>\d+(\.\d+)+)\.tar"
|
UPSTREAM_CHECK_REGEX = "qemu-(?P<pver>\d+(\.\d+)+)\.tar"
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
From 15222d4636d742f3395fd211fad0cd7e36d9f43e Mon Sep 17 00:00:00 2001
|
||||||
|
From: Hitendra Prajapati <hprajapati@mvista.com>
|
||||||
|
Date: Tue, 16 Aug 2022 10:07:01 +0530
|
||||||
|
Subject: [PATCH] CVE-2020-27821
|
||||||
|
|
||||||
|
Upstream-Status: Backport [https://git.qemu.org/?p=qemu.git;a=commit;h=4bfb024bc76973d40a359476dc0291f46e435442]
|
||||||
|
CVE: CVE-2020-27821
|
||||||
|
Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com>
|
||||||
|
|
||||||
|
memory: clamp cached translation in case it points to an MMIO region
|
||||||
|
|
||||||
|
In using the address_space_translate_internal API, address_space_cache_init
|
||||||
|
forgot one piece of advice that can be found in the code for
|
||||||
|
address_space_translate_internal:
|
||||||
|
|
||||||
|
/* MMIO registers can be expected to perform full-width accesses based only
|
||||||
|
* on their address, without considering adjacent registers that could
|
||||||
|
* decode to completely different MemoryRegions. When such registers
|
||||||
|
* exist (e.g. I/O ports 0xcf8 and 0xcf9 on most PC chipsets), MMIO
|
||||||
|
* regions overlap wildly. For this reason we cannot clamp the accesses
|
||||||
|
* here.
|
||||||
|
*
|
||||||
|
* If the length is small (as is the case for address_space_ldl/stl),
|
||||||
|
* everything works fine. If the incoming length is large, however,
|
||||||
|
* the caller really has to do the clamping through memory_access_size.
|
||||||
|
*/
|
||||||
|
|
||||||
|
address_space_cache_init is exactly one such case where "the incoming length
|
||||||
|
is large", therefore we need to clamp the resulting length---not to
|
||||||
|
memory_access_size though, since we are not doing an access yet, but to
|
||||||
|
the size of the resulting section. This ensures that subsequent accesses
|
||||||
|
to the cached MemoryRegionSection will be in range.
|
||||||
|
|
||||||
|
With this patch, the enclosed testcase notices that the used ring does
|
||||||
|
not fit into the MSI-X table and prints a "qemu-system-x86_64: Cannot map used"
|
||||||
|
error.
|
||||||
|
|
||||||
|
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
||||||
|
---
|
||||||
|
exec.c | 10 ++++++++++
|
||||||
|
1 file changed, 10 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/exec.c b/exec.c
|
||||||
|
index 2d6add46..1360051a 100644
|
||||||
|
--- a/exec.c
|
||||||
|
+++ b/exec.c
|
||||||
|
@@ -3632,6 +3632,7 @@ int64_t address_space_cache_init(MemoryRegionCache *cache,
|
||||||
|
AddressSpaceDispatch *d;
|
||||||
|
hwaddr l;
|
||||||
|
MemoryRegion *mr;
|
||||||
|
+ Int128 diff;
|
||||||
|
|
||||||
|
assert(len > 0);
|
||||||
|
|
||||||
|
@@ -3640,6 +3641,15 @@ int64_t address_space_cache_init(MemoryRegionCache *cache,
|
||||||
|
d = flatview_to_dispatch(cache->fv);
|
||||||
|
cache->mrs = *address_space_translate_internal(d, addr, &cache->xlat, &l, true);
|
||||||
|
|
||||||
|
+ /*
|
||||||
|
+ * cache->xlat is now relative to cache->mrs.mr, not to the section itself.
|
||||||
|
+ * Take that into account to compute how many bytes are there between
|
||||||
|
+ * cache->xlat and the end of the section.
|
||||||
|
+ */
|
||||||
|
+ diff = int128_sub(cache->mrs.size,
|
||||||
|
+ int128_make64(cache->xlat - cache->mrs.offset_within_region));
|
||||||
|
+ l = int128_get64(int128_min(diff, int128_make64(l)));
|
||||||
|
+
|
||||||
|
mr = cache->mrs.mr;
|
||||||
|
memory_region_ref(mr);
|
||||||
|
if (memory_access_is_direct(mr, is_write)) {
|
||||||
|
--
|
||||||
|
2.25.1
|
||||||
|
|
||||||
Reference in New Issue
Block a user