Skip to contentSkip to conversation

qemu: fix CVE-2021-20257

PATCH New Armin Kuster 1 participant 3 messages Aug 24, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 qemu: fix CVE-2021-20257

From: Sakib Sajal <[email protected]>

Source: https://git.yoctoproject.org/git/poky
MR: 110290
Type: Security Fix
Disposition: Backport from http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/meta/recipes-devtools/qemu?h=hardknott&id=5c1a29e6deec8f92ac43363bd72439aec7e27721
ChangeID: 7f301e939cf9d1fdb826ac47d1fc96430086a68e
Description:

(From OE-Core rev: 5b66ff7972951db973d12f3dae6ccecf3bc29e56)

(cherry picked from commit 547ac986a74cfcae39b691ebb92aadc8436443ea)
(cherry picked from commit 5c1a29e6deec8f92ac43363bd72439aec7e27721)
---
 meta/recipes-devtools/qemu/qemu.inc           |  1 +
 .../qemu/qemu/CVE-2021-20257.patch            | 55 +++++++++++++++++++
 2 files changed, 56 insertions(+)
 create mode 100644 meta/recipes-devtools/qemu/qemu/CVE-2021-20257.patch
meta/recipes-devtools/qemu/qemu.inc +1 -0
index e64a6b2cb2..1ddb373115 100644
@@ -71,6 +71,7 @@ SRC_URI = "https://download.qemu.org/${BPN}-${PV}.tar.xz \
            file://CVE-2021-3416_8.patch \
            file://CVE-2021-3416_9.patch \
            file://CVE-2021-3416_10.patch \
+           file://CVE-2021-20257.patch \
            "
 UPSTREAM_CHECK_REGEX = "qemu-(?P<pver>\d+(\.\d+)+)\.tar"
 
meta/recipes-devtools/qemu/qemu/CVE-2021-20257.patch new file +55 -0

55 lines not on this page · raw message

Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/3 qemu: Security fix CVE-2021-3544

From: Armin Kuster <[email protected]>

Source: qemu.org
MR: 111833
Type: Security Fix
Disposition: Backport from https://gitlab.com/qemu-project/qemu/-/commit/86dd8fac..63736af5
ChangeID: 7f301e939cf9d1fdb826ac47d1fc96430086a68e
Description:

https://gitlab.com/qemu-project/qemu/-/commit/86dd8fac
https://gitlab.com/qemu-project/qemu/-/commit/b9f79858
https://gitlab.com/qemu-project/qemu/-/commit/b7afebcf
Tweeked the above patches as vhost-user-gpu.c does not exist.

https://gitlab.com/qemu-project/qemu/-/commit/f6091d86
https://gitlab.com/qemu-project/qemu/-/commit/63736af5

---
 meta/recipes-devtools/qemu/qemu.inc           |  5 ++
 .../qemu/qemu/CVE-2021-3544.patch             | 29 ++++++++++++
 .../qemu/qemu/CVE-2021-3544_2.patch           | 39 +++++++++++++++
 .../qemu/qemu/CVE-2021-3544_3.patch           | 39 +++++++++++++++
 .../qemu/qemu/CVE-2021-3544_4.patch           | 46 ++++++++++++++++++
 .../qemu/qemu/CVE-2021-3544_5.patch           | 47 +++++++++++++++++++
 6 files changed, 205 insertions(+)
 create mode 100644 meta/recipes-devtools/qemu/qemu/CVE-2021-3544.patch
 create mode 100644 meta/recipes-devtools/qemu/qemu/CVE-2021-3544_2.patch
 create mode 100644 meta/recipes-devtools/qemu/qemu/CVE-2021-3544_3.patch
 create mode 100644 meta/recipes-devtools/qemu/qemu/CVE-2021-3544_4.patch
 create mode 100644 meta/recipes-devtools/qemu/qemu/CVE-2021-3544_5.patch
meta/recipes-devtools/qemu/qemu.inc +5 -0
index 1ddb373115..90549136e5 100644
@@ -72,6 +72,11 @@ SRC_URI = "https://download.qemu.org/${BPN}-${PV}.tar.xz \
            file://CVE-2021-3416_9.patch \
            file://CVE-2021-3416_10.patch \
            file://CVE-2021-20257.patch \
+           file://CVE-2021-3544.patch \
+           file://CVE-2021-3544_2.patch \
+           file://CVE-2021-3544_3.patch \
+           file://CVE-2021-3544_4.patch \
+           file://CVE-2021-3544_5.patch \
            "
 UPSTREAM_CHECK_REGEX = "qemu-(?P<pver>\d+(\.\d+)+)\.tar"
 
meta/recipes-devtools/qemu/qemu/CVE-2021-3544.patch new file +29 -0
new file mode 100644
index 0000000000..1b4fcbfb60
@@ -0,0 +1,29 @@
+vhost-user-gpu: fix resource leak in 'vg_resource_create_2d' (CVE-2021-3544)
+
+Call 'vugbm_buffer_destroy' in error path to avoid resource leak.
+
+Fixes: CVE-2021-3544
+Reported-by: default avatarLi Qiang <[email protected]>
+Reviewed-by: default avatarPrasad J Pandit <[email protected]>
+Signed-off-by: default avatarLi Qiang <[email protected]>
+Reviewed-by: Marc-André Lureau's avatarMarc-André Lureau <[email protected]>
+Message-Id: <[email protected]>
+Signed-off-by: Gerd Hoffmann's avatarGerd Hoffmann <[email protected]>
+
+Upstream-Status: Backport
+[vhost-user-gpu does not exist in 4.2.0]
+CVE: CVE-2021-3544
+Signed-off-by: Armin Kuster <[email protected]>
+
+Index: qemu-4.2.0/contrib/vhost-user-gpu/main.c
+===================================================================
+--- qemu-4.2.0.orig/contrib/vhost-user-gpu/main.c
++++ qemu-4.2.0/contrib/vhost-user-gpu/main.c
+@@ -328,6 +328,7 @@ vg_resource_create_2d(VuGpu *g,
+         g_critical("%s: resource creation failed %d %d %d",
+                    __func__, c2d.resource_id, c2d.width, c2d.height);
+         g_free(res);
++        vugbm_buffer_destroy(&res->buffer);
+         cmd->error = VIRTIO_GPU_RESP_ERR_OUT_OF_MEMORY;
+         return;
+     }
meta/recipes-devtools/qemu/qemu/CVE-2021-3544_2.patch new file +39 -0
new file mode 100644
index 0000000000..36cbb127f8
@@ -0,0 +1,39 @@
+vhost-user-gpu: fix memory leak in vg_resource_attach_backing (CVE-2021-3544)
+
+
+Check whether the 'res' has already been attach_backing to avoid
+memory leak.
+
+Fixes: CVE-2021-3544
+Reported-by: default avatarLi Qiang <[email protected]>
+virtio-gpu fix: 204f01b3
+
+ ("virtio-gpu: fix memory leak
+ in resource attach backing")
+ Signed-off-by: default avatarLi Qiang <[email protected]>
+ Reviewed-by: Marc-André Lureau's avatarMarc-André Lureau <[email protected]>
+ Message-Id: <[email protected]>
+ Signed-off-by: Gerd Hoffmann's avatarGerd Hoffmann <[email protected]>
+
+Upstream-Status: Backport
+[vhost-user-gpu does not exist in 4.2.0 context]
+CVE: CVE-2021-3544
+Signed-off-by: Armin Kuster <[email protected]>
+
+
+Index: qemu-4.2.0/contrib/vhost-user-gpu/main.c
+===================================================================
+--- qemu-4.2.0.orig/contrib/vhost-user-gpu/main.c
++++ qemu-4.2.0/contrib/vhost-user-gpu/main.c
+@@ -468,6 +468,11 @@ vg_resource_attach_backing(VuGpu *g,
+         return;
+     }
+ 
++    if (res->iov) {
++        cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
++        return;
++    }
++
+     ret = vg_create_mapping_iov(g, &ab, cmd, &res->iov);
+     if (ret != 0) {
+         cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
meta/recipes-devtools/qemu/qemu/CVE-2021-3544_3.patch new file +39 -0
new file mode 100644
index 0000000000..c534f4c24f
@@ -0,0 +1,39 @@
+vhost-user-gpu: fix memory leak while calling 'vg_resource_unref' (CVE-2021-3544)
+
+If the guest trigger following sequences, the attach_backing will be leaked:
+
+vg_resource_create_2d
+vg_resource_attach_backing
+vg_resource_unref
+
+This patch fix this by freeing 'res->iov' in vg_resource_destroy.
+
+Fixes: CVE-2021-3544
+Reported-by: default avatarLi Qiang <[email protected]>
+virtio-gpu fix: 5e8e3c4c
+
+("virtio-gpu: fix resource leak
+in virgl_cmd_resource_unref")
+Reviewed-by: default avatarPrasad J Pandit <[email protected]>
+Signed-off-by: default avatarLi Qiang <[email protected]>
+Reviewed-by: Marc-André Lureau's avatarMarc-André Lureau <[email protected]>
+Message-Id: <[email protected]>
+Signed-off-by: Gerd Hoffmann's avatarGerd Hoffmann <[email protected]>
+
+Upstream-Status: Backport
+CVE: CVE-2021-3544
+[vhost-user-gpu does not exist in the 4.2.0]
+Signed-off-by: Armin Kuster <[email protected]>
+
+Index: qemu-4.2.0/contrib/vhost-user-gpu/main.c
+===================================================================
+--- qemu-4.2.0.orig/contrib/vhost-user-gpu/main.c
++++ qemu-4.2.0/contrib/vhost-user-gpu/main.c
+@@ -379,6 +379,7 @@ vg_resource_destroy(VuGpu *g,
+     }
+ 
+     vugbm_buffer_destroy(&res->buffer);
++    g_free(res->iov);
+     pixman_image_unref(res->image);
+     QTAILQ_REMOVE(&g->reslist, res, next);
+     g_free(res);
meta/recipes-devtools/qemu/qemu/CVE-2021-3544_4.patch new file +46 -0

46 lines not on this page · raw message

meta/recipes-devtools/qemu/qemu/CVE-2021-3544_5.patch new file +47 -0

47 lines not on this page · raw message

Signature · 1 line
2.25.1
#2 lore raw

PATCH 3/3 qemu: Security fixes CVE-2021-3545/6

In reply to Armin Kuster

From: Armin Kuster <[email protected]>

Source: qemu.org
MR: 111845, 111839
Type: Security Fix
Disposition: Backport from https://gitlab.com/qemu-project/qemu/-/commit/9f22893a & 121841b2
ChangeID: 111b168e0fe4d2a722158c6bfdaceb06a8789e69
Description:

Fixes CVE-2021-3545 and CVE-2021-3546
---
 meta/recipes-devtools/qemu/qemu.inc           |  2 +
 .../qemu/qemu/CVE-2021-3545.patch             | 41 ++++++++++++++++
 .../qemu/qemu/CVE-2021-3546.patch             | 47 +++++++++++++++++++
 3 files changed, 90 insertions(+)
 create mode 100644 meta/recipes-devtools/qemu/qemu/CVE-2021-3545.patch
 create mode 100644 meta/recipes-devtools/qemu/qemu/CVE-2021-3546.patch
meta/recipes-devtools/qemu/qemu.inc +2 -0
index 90549136e5..028b81ee34 100644
@@ -77,6 +77,8 @@ SRC_URI = "https://download.qemu.org/${BPN}-${PV}.tar.xz \
            file://CVE-2021-3544_3.patch \
            file://CVE-2021-3544_4.patch \
            file://CVE-2021-3544_5.patch \
+           file://CVE-2021-3545.patch \
+           file://CVE-2021-3546.patch \
            "
 UPSTREAM_CHECK_REGEX = "qemu-(?P<pver>\d+(\.\d+)+)\.tar"
 
meta/recipes-devtools/qemu/qemu/CVE-2021-3545.patch new file +41 -0

41 lines not on this page · raw message

meta/recipes-devtools/qemu/qemu/CVE-2021-3546.patch new file +47 -0

47 lines not on this page · raw message

Signature · 1 line
2.25.1