summaryrefslogtreecommitdiffstats
path: root/meta-networking/recipes-support
diff options
context:
space:
mode:
authorGyorgy Sarvari <skandigraun@gmail.com>2025-11-14 20:45:21 +0100
committerGyorgy Sarvari <skandigraun@gmail.com>2025-11-30 15:13:57 +0100
commitb5a19849c52b8f397ea90a720cf58b2c5d7bc791 (patch)
tree6851816b9c1f76d72811cd364e854e14635a1f95 /meta-networking/recipes-support
parenteeda504ce925e87546a902527cc3f21c641e5fad (diff)
downloadmeta-openembedded-b5a19849c52b8f397ea90a720cf58b2c5d7bc791.tar.gz
usbredir: patch CVE-2021-3700
Details: https://nvd.nist.gov/vuln/detail/CVE-2021-3700 Pick the patch mentioned in the nvd report. Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
Diffstat (limited to 'meta-networking/recipes-support')
-rw-r--r--meta-networking/recipes-support/spice/usbredir/CVE-2021-3700.patch74
-rw-r--r--meta-networking/recipes-support/spice/usbredir_0.9.0.bb4
2 files changed, 77 insertions, 1 deletions
diff --git a/meta-networking/recipes-support/spice/usbredir/CVE-2021-3700.patch b/meta-networking/recipes-support/spice/usbredir/CVE-2021-3700.patch
new file mode 100644
index 0000000000..4804e740b5
--- /dev/null
+++ b/meta-networking/recipes-support/spice/usbredir/CVE-2021-3700.patch
@@ -0,0 +1,74 @@
1From 4851f8d4538e0a25992619ad96a2366c1632e46e Mon Sep 17 00:00:00 2001
2From: Michael Hanselmann <public@hansmi.ch>
3Date: Sun, 8 Aug 2021 15:35:58 +0200
4Subject: [PATCH] Avoid use-after-free in serialization
5
6Serializing parsers with large amounts of buffered write data (e.g. in case of
7a slow or blocked write destination) would cause "serialize_data" to reallocate
8the state buffer whose default size is 64kB (USBREDIRPARSER_SERIALIZE_BUF_SIZE).
9The pointer to the position for the write buffer count would then point to
10a location outside the buffer where the number of write buffers would be written
11as a 32-bit value.
12
13As of QEMU 5.2.0 the serializer is invoked for migrations. Serializations for
14migrations may happen regularily such as when using the COLO feature[1].
15Serialization happens under QEMU's I/O lock. The guest can't control the state
16while the serialization is happening. The value written is the number of
17outstanding buffers which would be suceptible to timing and host system system
18load. The guest would have to continously groom the write buffers. A useful
19value needs to be allocated in the exact position freed during the buffer size
20increase, but before the buffer count is written. The author doesn't consider it
21realistic to exploit this use-after-free reliably.
22
23[1] https://wiki.qemu.org/Features/COLO
24
25Signed-off-by: Michael Hanselmann <public@hansmi.ch>
26
27CVE: CVE-2021-3700
28Upstream-Status: Backport [https://gitlab.freedesktop.org/spice/usbredir/-/commit/03c519ff5831ba]
29Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
30---
31 usbredirparser/usbredirparser.c | 8 +++++---
32 1 file changed, 5 insertions(+), 3 deletions(-)
33
34diff --git a/usbredirparser/usbredirparser.c b/usbredirparser/usbredirparser.c
35index ba8edb4..ccd3078 100644
36--- a/usbredirparser/usbredirparser.c
37+++ b/usbredirparser/usbredirparser.c
38@@ -20,6 +20,7 @@
39 */
40 #include "config.h"
41
42+#include <stddef.h>
43 #include <stdio.h>
44 #include <stdlib.h>
45 #include <stdarg.h>
46@@ -1594,8 +1595,9 @@ int usbredirparser_serialize(struct usbredirparser *parser_pub,
47 struct usbredirparser_priv *parser =
48 (struct usbredirparser_priv *)parser_pub;
49 struct usbredirparser_buf *wbuf;
50- uint8_t *write_buf_count_pos, *state = NULL, *pos = NULL;
51+ uint8_t *state = NULL, *pos = NULL;
52 uint32_t write_buf_count = 0, len, remain = 0;
53+ ptrdiff_t write_buf_count_pos;
54
55 *state_dest = NULL;
56 *state_len = 0;
57@@ -1640,7 +1642,7 @@ int usbredirparser_serialize(struct usbredirparser *parser_pub,
58 parser->data, parser->data_read, "packet-data"))
59 return -1;
60
61- write_buf_count_pos = pos;
62+ write_buf_count_pos = pos - state;
63 /* To be replaced with write_buf_count later */
64 if (serialize_int(parser, &state, &pos, &remain, 0, "write_buf_count"))
65 return -1;
66@@ -1655,7 +1657,7 @@ int usbredirparser_serialize(struct usbredirparser *parser_pub,
67 wbuf = wbuf->next;
68 }
69 /* Patch in write_buf_count */
70- memcpy(write_buf_count_pos, &write_buf_count, sizeof(int32_t));
71+ memcpy(state + write_buf_count_pos, &write_buf_count, sizeof(int32_t));
72
73 /* Patch in length */
74 len = pos - state;
diff --git a/meta-networking/recipes-support/spice/usbredir_0.9.0.bb b/meta-networking/recipes-support/spice/usbredir_0.9.0.bb
index edd8aeb9c3..bf0d87065e 100644
--- a/meta-networking/recipes-support/spice/usbredir_0.9.0.bb
+++ b/meta-networking/recipes-support/spice/usbredir_0.9.0.bb
@@ -9,7 +9,9 @@ DEPENDS = "libusb1"
9 9
10SRCREV = "bca484fc6f206ab9da2f73e8a0118fad45374d4e" 10SRCREV = "bca484fc6f206ab9da2f73e8a0118fad45374d4e"
11 11
12SRC_URI = "git://gitlab.freedesktop.org/spice/usbredir;branch=main;protocol=https" 12SRC_URI = "git://gitlab.freedesktop.org/spice/usbredir;branch=main;protocol=https \
13 file://CVE-2021-3700.patch \
14 "
13 15
14S = "${WORKDIR}/git" 16S = "${WORKDIR}/git"
15 17