diff options
author | Yogita Urade <yogita.urade@windriver.com> | 2023-08-10 07:00:10 +0000 |
---|---|---|
committer | Steve Sakoman <steve@sakoman.com> | 2023-08-18 03:57:04 -1000 |
commit | f86817b160796816a5d6715254cd36b5d1239c02 (patch) | |
tree | 6a7f3235326f16dba97a37a7d0c2e9b265b4c317 | |
parent | b4a1f9785552f38d9f81d5b575deb1f59dcd51d0 (diff) | |
download | poky-f86817b160796816a5d6715254cd36b5d1239c02.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
Reference:
https://nvd.nist.gov/vuln/detail/CVE-2023-3301
(From OE-Core rev: 82bf6c4cba88dc9f25caf14d60e79ce0c366919c)
Signed-off-by: Yogita Urade <yogita.urade@windriver.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rw-r--r-- | meta/recipes-devtools/qemu/qemu.inc | 1 | ||||
-rw-r--r-- | meta/recipes-devtools/qemu/qemu/CVE-2023-3301.patch | 65 |
2 files changed, 66 insertions, 0 deletions
diff --git a/meta/recipes-devtools/qemu/qemu.inc b/meta/recipes-devtools/qemu/qemu.inc index 15eba6163f..c1ac245f9f 100644 --- a/meta/recipes-devtools/qemu/qemu.inc +++ b/meta/recipes-devtools/qemu/qemu.inc | |||
@@ -37,6 +37,7 @@ SRC_URI = "https://download.qemu.org/${BPN}-${PV}.tar.xz \ | |||
37 | file://qemu-guest-agent.udev \ | 37 | file://qemu-guest-agent.udev \ |
38 | file://ppc.patch \ | 38 | file://ppc.patch \ |
39 | file://CVE-2023-0330.patch \ | 39 | file://CVE-2023-0330.patch \ |
40 | file://CVE-2023-3301.patch \ | ||
40 | " | 41 | " |
41 | UPSTREAM_CHECK_REGEX = "qemu-(?P<pver>\d+(\.\d+)+)\.tar" | 42 | UPSTREAM_CHECK_REGEX = "qemu-(?P<pver>\d+(\.\d+)+)\.tar" |
42 | 43 | ||
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..977f017ed2 --- /dev/null +++ b/meta/recipes-devtools/qemu/qemu/CVE-2023-3301.patch | |||
@@ -0,0 +1,65 @@ | |||
1 | From a0d7215e339b61c7d7a7b3fcf754954d80d93eb8 Sep 17 00:00:00 2001 | ||
2 | From: Ani Sinha <anisinha@redhat.com> | ||
3 | Date: Wed, 2 Aug 2023 09:25:27 +0000 | ||
4 | Subject: [PATCH] vhost-vdpa: do not cleanup the vdpa/vhost-net structures if | ||
5 | peer nic is present | ||
6 | |||
7 | When a peer nic is still attached to the vdpa backend, it is too early to free | ||
8 | up the vhost-net and vdpa structures. If these structures are freed here, then | ||
9 | QEMU crashes when the guest is being shut down. The following call chain | ||
10 | would result in an assertion failure since the pointer returned from | ||
11 | vhost_vdpa_get_vhost_net() would be NULL: | ||
12 | |||
13 | do_vm_stop() -> vm_state_notify() -> virtio_set_status() -> | ||
14 | virtio_net_vhost_status() -> get_vhost_net(). | ||
15 | |||
16 | Therefore, we defer freeing up the structures until at guest shutdown | ||
17 | time when qemu_cleanup() calls net_cleanup() which then calls | ||
18 | qemu_del_net_client() which would eventually call vhost_vdpa_cleanup() | ||
19 | again to free up the structures. This time, the loop in net_cleanup() | ||
20 | ensures that vhost_vdpa_cleanup() will be called one last time when | ||
21 | all the peer nics are detached and freed. | ||
22 | |||
23 | All unit tests pass with this change. | ||
24 | |||
25 | CC: imammedo@redhat.com | ||
26 | CC: jusual@redhat.com | ||
27 | CC: mst@redhat.com | ||
28 | Fixes: CVE-2023-3301 | ||
29 | Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2128929 | ||
30 | Signed-off-by: Ani Sinha <anisinha@redhat.com> | ||
31 | Message-Id: <20230619065209.442185-1-anisinha@redhat.com> | ||
32 | Reviewed-by: Michael S. Tsirkin <mst@redhat.com> | ||
33 | Signed-off-by: Michael S. Tsirkin <mst@redhat.com> | ||
34 | |||
35 | CVE: CVE-2023-3301 | ||
36 | |||
37 | Upstream-Status: Backport [https://github.com/qemu/qemu/commit/a0d7215e339b61c7d7a7b3fcf754954d80d93eb8] | ||
38 | |||
39 | Signed-off-by: Yogita Urade <yogita.urade@windriver.com> | ||
40 | --- | ||
41 | net/vhost-vdpa.c | 9 +++++++++ | ||
42 | 1 file changed, 9 insertions(+) | ||
43 | |||
44 | diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c | ||
45 | index 2b4b85d8f..8dbe929c1 100644 | ||
46 | --- a/net/vhost-vdpa.c | ||
47 | +++ b/net/vhost-vdpa.c | ||
48 | @@ -158,6 +158,15 @@ err_init: | ||
49 | static void vhost_vdpa_cleanup(NetClientState *nc) | ||
50 | { | ||
51 | VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc); | ||
52 | + | ||
53 | + /* | ||
54 | + * If a peer NIC is attached, do not cleanup anything. | ||
55 | + * Cleanup will happen as a part of qemu_cleanup() -> net_cleanup() | ||
56 | + * when the guest is shutting down. | ||
57 | + */ | ||
58 | + if (nc->peer && nc->peer->info->type == NET_CLIENT_DRIVER_NIC) { | ||
59 | + return; | ||
60 | + } | ||
61 | struct vhost_dev *dev = &s->vhost_net->dev; | ||
62 | |||
63 | qemu_vfree(s->cvq_cmd_out_buffer); | ||
64 | -- | ||
65 | 2.40.0 | ||