summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArchana Polampalli <archana.polampalli@windriver.com>2023-08-01 04:17:46 +0000
committerSteve Sakoman <steve@sakoman.com>2023-08-07 04:40:43 -1000
commit2587c36e870ed0b4363e59444bad160b46e8959b (patch)
tree37f0938b3c1198372df808a54e2c19d7dcbcbc5e
parentcd329fc98420f69ec17aa8b619ed1e39f050db99 (diff)
downloadpoky-2587c36e870ed0b4363e59444bad160b46e8959b.tar.gz
qemu: fix CVE-2023-3301
qemu: hotplug/hotunplug mlx vdpa device to the occupied addr port, then qemu core dump occurs after shutdown guest References: https://nvd.nist.gov/vuln/detail/CVE-2023-3301 Upstream patches: https://gitlab.com/qemu-project/qemu/-/commit/a0d7215e339b61c7d7a7b3fcf754954d80d93eb8 (From OE-Core rev: f549ff6db018f66a80fc65987675e8bb6afcd002) Signed-off-by: Archana Polampalli <archana.polampalli@windriver.com> Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rw-r--r--meta/recipes-devtools/qemu/qemu.inc1
-rw-r--r--meta/recipes-devtools/qemu/qemu/CVE-2023-3301.patch60
2 files changed, 61 insertions, 0 deletions
diff --git a/meta/recipes-devtools/qemu/qemu.inc b/meta/recipes-devtools/qemu/qemu.inc
index c6c6e49ebf..d5d210194b 100644
--- a/meta/recipes-devtools/qemu/qemu.inc
+++ b/meta/recipes-devtools/qemu/qemu.inc
@@ -94,6 +94,7 @@ SRC_URI = "https://download.qemu.org/${BPN}-${PV}.tar.xz \
94 file://0001-hw-display-qxl-Have-qxl_log_command-Return-early-if-.patch \ 94 file://0001-hw-display-qxl-Have-qxl_log_command-Return-early-if-.patch \
95 file://0001-hw-display-qxl-Pass-requested-buffer-size-to-qxl_phy.patch \ 95 file://0001-hw-display-qxl-Pass-requested-buffer-size-to-qxl_phy.patch \
96 file://CVE-2023-0330.patch \ 96 file://CVE-2023-0330.patch \
97 file://CVE-2023-3301.patch \
97 " 98 "
98UPSTREAM_CHECK_REGEX = "qemu-(?P<pver>\d+(\.\d+)+)\.tar" 99UPSTREAM_CHECK_REGEX = "qemu-(?P<pver>\d+(\.\d+)+)\.tar"
99 100
diff --git a/meta/recipes-devtools/qemu/qemu/CVE-2023-3301.patch b/meta/recipes-devtools/qemu/qemu/CVE-2023-3301.patch
new file mode 100644
index 0000000000..ffb5cd3861
--- /dev/null
+++ b/meta/recipes-devtools/qemu/qemu/CVE-2023-3301.patch
@@ -0,0 +1,60 @@
1From a0d7215e339b61c7d7a7b3fcf754954d80d93eb8 Mon Sep 17 00:00:00 2001
2From: Ani Sinha <anisinha@redhat.com>
3Date: Mon, 19 Jun 2023 12:22:09 +0530
4Subject: [PATCH] vhost-vdpa: do not cleanup the vdpa/vhost-net structures if
5 peer nic is present
6
7When a peer nic is still attached to the vdpa backend, it is too early to free
8up the vhost-net and vdpa structures. If these structures are freed here, then
9QEMU crashes when the guest is being shut down. The following call chain
10would result in an assertion failure since the pointer returned from
11vhost_vdpa_get_vhost_net() would be NULL:
12
13do_vm_stop() -> vm_state_notify() -> virtio_set_status() ->
14virtio_net_vhost_status() -> get_vhost_net().
15
16Therefore, we defer freeing up the structures until at guest shutdown
17time when qemu_cleanup() calls net_cleanup() which then calls
18qemu_del_net_client() which would eventually call vhost_vdpa_cleanup()
19again to free up the structures. This time, the loop in net_cleanup()
20ensures that vhost_vdpa_cleanup() will be called one last time when
21all the peer nics are detached and freed.
22
23All unit tests pass with this change.
24
25CC: imammedo@redhat.com
26CC: jusual@redhat.com
27CC: mst@redhat.com
28Fixes: CVE-2023-3301
29Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2128929
30Signed-off-by: Ani Sinha <anisinha@redhat.com>
31Message-Id: <20230619065209.442185-1-anisinha@redhat.com>
32Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
33Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
34
35Upstream-Status: Backport [https://github.com/qemu/qemu/commit/a0d7215e339b61c7d7a7b3fcf754954d80d93eb8]
36CVE: CVE-2023-3301
37
38
39Signed-off-by: Archana Polampalli <archana.polampalli@windriver.com>
40---
41 net/vhost-vdpa.c | 8 ++++++++
42 1 file changed, 8 insertions(+)
43
44--- a/net/vhost-vdpa.c
45+++ b/net/vhost-vdpa.c
46@@ -140,6 +140,14 @@ static void vhost_vdpa_cleanup(NetClient
47 {
48 VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc);
49
50+ /*
51+ * If a peer NIC is attached, do not cleanup anything.
52+ * Cleanup will happen as a part of qemu_cleanup() -> net_cleanup()
53+ * when the guest is shutting down.
54+ */
55+ if (nc->peer && nc->peer->info->type == NET_CLIENT_DRIVER_NIC) {
56+ return;
57+ }
58 if (s->vhost_net) {
59 vhost_net_cleanup(s->vhost_net);
60 g_free(s->vhost_net);