Skip to content

Commit 6e982cb

Browse files
nicogbgNicolas Guibourge
andauthored
qemu : fix CVE-2022-35414 (#3597)
* qemu : fix CVE-2022-35414 * address PR comment Co-authored-by: Nicolas Guibourge <[email protected]>
1 parent 046e178 commit 6e982cb

File tree

2 files changed

+69
-1
lines changed

2 files changed

+69
-1
lines changed

SPECS/qemu/CVE-2022-35414.patch

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
From 418ade7849ce7641c0f7333718caf5091a02fd4c Mon Sep 17 00:00:00 2001
2+
From: Richard Henderson <[email protected]>
3+
Date: Tue, 21 Jun 2022 08:38:29 -0700
4+
Subject: [PATCH] softmmu: Always initialize xlat in
5+
address_space_translate_for_iotlb
6+
7+
The bug is an uninitialized memory read, along the translate_fail
8+
path, which results in garbage being read from iotlb_to_section,
9+
which can lead to a crash in io_readx/io_writex.
10+
11+
The bug may be fixed by writing any value with zero
12+
in ~TARGET_PAGE_MASK, so that the call to iotlb_to_section using
13+
the xlat'ed address returns io_mem_unassigned, as desired by the
14+
translate_fail path.
15+
16+
It is most useful to record the original physical page address,
17+
which will eventually be logged by memory_region_access_valid
18+
when the access is rejected by unassigned_mem_accepts.
19+
20+
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1065
21+
Signed-off-by: Richard Henderson <[email protected]>
22+
Reviewed-by: Peter Maydell <[email protected]>
23+
Message-Id: <[email protected]>
24+
---
25+
softmmu/physmem.c | 13 ++++++++++++-
26+
1 file changed, 12 insertions(+), 1 deletion(-)
27+
28+
diff --git a/softmmu/physmem.c b/softmmu/physmem.c
29+
index fb16be57a6c6..dc3c3e5f2e70 100644
30+
--- a/softmmu/physmem.c
31+
+++ b/softmmu/physmem.c
32+
@@ -669,7 +669,7 @@ void tcg_iommu_init_notifier_list(CPUState *cpu)
33+
34+
/* Called from RCU critical section */
35+
MemoryRegionSection *
36+
-address_space_translate_for_iotlb(CPUState *cpu, int asidx, hwaddr addr,
37+
+address_space_translate_for_iotlb(CPUState *cpu, int asidx, hwaddr orig_addr,
38+
hwaddr *xlat, hwaddr *plen,
39+
MemTxAttrs attrs, int *prot)
40+
{
41+
@@ -678,6 +678,7 @@ address_space_translate_for_iotlb(CPUState *cpu, int asidx, hwaddr addr,
42+
IOMMUMemoryRegionClass *imrc;
43+
IOMMUTLBEntry iotlb;
44+
int iommu_idx;
45+
+ hwaddr addr = orig_addr;
46+
AddressSpaceDispatch *d =
47+
qatomic_rcu_read(&cpu->cpu_ases[asidx].memory_dispatch);
48+
49+
@@ -722,6 +723,16 @@ address_space_translate_for_iotlb(CPUState *cpu, int asidx, hwaddr addr,
50+
return section;
51+
52+
translate_fail:
53+
+ /*
54+
+ * We should be given a page-aligned address -- certainly
55+
+ * tlb_set_page_with_attrs() does so. The page offset of xlat
56+
+ * is used to index sections[], and PHYS_SECTION_UNASSIGNED = 0.
57+
+ * The page portion of xlat will be logged by memory_region_access_valid()
58+
+ * when this memory access is rejected, so use the original untranslated
59+
+ * physical address.
60+
+ */
61+
+ assert((orig_addr & ~TARGET_PAGE_MASK) == 0);
62+
+ *xlat = orig_addr;
63+
return &d->map.sections[PHYS_SECTION_UNASSIGNED];
64+
}

SPECS/qemu/qemu.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ Obsoletes: %{name}-system-unicore32-core <= %{version}-%{release}
217217
Summary: QEMU is a FAST! processor emulator
218218
Name: qemu
219219
Version: 6.2.0
220-
Release: 5%{?dist}
220+
Release: 6%{?dist}
221221
License: BSD AND CC-BY AND GPLv2+ AND LGPLv2+ AND MIT
222222
Vendor: Microsoft Corporation
223223
Distribution: Mariner
@@ -256,6 +256,7 @@ Patch1002: CVE-2022-1050.patch
256256
Patch1003: CVE-2022-26354.patch
257257
Patch1004: CVE-2022-26353.patch
258258
Patch1005: CVE-2021-4206.patch
259+
Patch1006: CVE-2022-35414.patch
259260

260261
# alsa audio output
261262
BuildRequires: alsa-lib-devel
@@ -2282,6 +2283,9 @@ useradd -r -u 107 -g qemu -G kvm -d / -s %{_sbindir}/nologin \
22822283

22832284

22842285
%changelog
2286+
* Tue Aug 23 2022 Nicolas Guibourge <[email protected]> - 6.2.0-6
2287+
- address CVE-2022-35414
2288+
22852289
* Fri Jul 01 2022 Muhammad Falak <[email protected]> - 6.2.0-5
22862290
- Ship efi*rom & pxe*rom rom files
22872291

0 commit comments

Comments
 (0)