From: "John Helmert III" <ajak@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: app-emulation/qemu/files/, app-emulation/qemu/
Date: Tue, 21 Dec 2021 23:53:25 +0000 (UTC) [thread overview]
Message-ID: <1640130137.0ad99be8a35aff4afc249dd3b596b2eed6b5c884.ajak@gentoo> (raw)
commit: 0ad99be8a35aff4afc249dd3b596b2eed6b5c884
Author: John Helmert III <ajak <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 21 23:29:36 2021 +0000
Commit: John Helmert III <ajak <AT> gentoo <DOT> org>
CommitDate: Tue Dec 21 23:42:17 2021 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0ad99be8
app-emulation/qemu: fix unix socket path copy
This adds a patch of upstream commit
118d527f2e4baec5fe8060b22a6212468b8e4d3f. It is included in 6.2.0, but
fixes a 6.1.0 regression, so committing straight to stable.
Signed-off-by: John Helmert III <ajak <AT> gentoo.org>
.../files/qemu-6.1.0-fix-unix-socket-copy.patch | 76 ++++++++++++++++++++++
.../{qemu-6.1.0-r2.ebuild => qemu-6.1.0-r3.ebuild} | 1 +
2 files changed, 77 insertions(+)
diff --git a/app-emulation/qemu/files/qemu-6.1.0-fix-unix-socket-copy.patch b/app-emulation/qemu/files/qemu-6.1.0-fix-unix-socket-copy.patch
new file mode 100644
index 000000000000..7701b26b4f9a
--- /dev/null
+++ b/app-emulation/qemu/files/qemu-6.1.0-fix-unix-socket-copy.patch
@@ -0,0 +1,76 @@
+commit 118d527f2e4baec5fe8060b22a6212468b8e4d3f
+Author: Michael Tokarev <mjt@tls.msk.ru>
+Date: Wed Sep 1 16:16:24 2021 +0300
+
+ qemu-sockets: fix unix socket path copy (again)
+
+ Commit 4cfd970ec188558daa6214f26203fe553fb1e01f added an
+ assert which ensures the path within an address of a unix
+ socket returned from the kernel is at least one byte and
+ does not exceed sun_path buffer. Both of this constraints
+ are wrong:
+
+ A unix socket can be unnamed, in this case the path is
+ completely empty (not even \0)
+
+ And some implementations (notable linux) can add extra
+ trailing byte (\0) _after_ the sun_path buffer if we
+ passed buffer larger than it (and we do).
+
+ So remove the assertion (since it causes real-life breakage)
+ but at the same time fix the usage of sun_path. Namely,
+ we should not access sun_path[0] if kernel did not return
+ it at all (this is the case for unnamed sockets),
+ and use the returned salen when copyig actual path as an
+ upper constraint for the amount of bytes to copy - this
+ will ensure we wont exceed the information provided by
+ the kernel, regardless whenever there is a trailing \0
+ or not. This also helps with unnamed sockets.
+
+ Note the case of abstract socket, the sun_path is actually
+ a blob and can contain \0 characters, - it should not be
+ passed to g_strndup and the like, it should be accessed by
+ memcpy-like functions.
+
+ Fixes: 4cfd970ec188558daa6214f26203fe553fb1e01f
+ Fixes: http://bugs.debian.org/993145
+ Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
+ Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
+ Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
+ CC: qemu-stable@nongnu.org
+
+diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
+index f2f3676d1f..c5043999e9 100644
+--- a/util/qemu-sockets.c
++++ b/util/qemu-sockets.c
+@@ -1345,25 +1345,22 @@ socket_sockaddr_to_address_unix(struct sockaddr_storage *sa,
+ SocketAddress *addr;
+ struct sockaddr_un *su = (struct sockaddr_un *)sa;
+
+- assert(salen >= sizeof(su->sun_family) + 1 &&
+- salen <= sizeof(struct sockaddr_un));
+-
+ addr = g_new0(SocketAddress, 1);
+ addr->type = SOCKET_ADDRESS_TYPE_UNIX;
++ salen -= offsetof(struct sockaddr_un, sun_path);
+ #ifdef CONFIG_LINUX
+- if (!su->sun_path[0]) {
++ if (salen > 0 && !su->sun_path[0]) {
+ /* Linux abstract socket */
+- addr->u.q_unix.path = g_strndup(su->sun_path + 1,
+- salen - sizeof(su->sun_family) - 1);
++ addr->u.q_unix.path = g_strndup(su->sun_path + 1, salen - 1);
+ addr->u.q_unix.has_abstract = true;
+ addr->u.q_unix.abstract = true;
+ addr->u.q_unix.has_tight = true;
+- addr->u.q_unix.tight = salen < sizeof(*su);
++ addr->u.q_unix.tight = salen < sizeof(su->sun_path);
+ return addr;
+ }
+ #endif
+
+- addr->u.q_unix.path = g_strndup(su->sun_path, sizeof(su->sun_path));
++ addr->u.q_unix.path = g_strndup(su->sun_path, salen);
+ return addr;
+ }
+ #endif /* WIN32 */
diff --git a/app-emulation/qemu/qemu-6.1.0-r2.ebuild b/app-emulation/qemu/qemu-6.1.0-r3.ebuild
similarity index 99%
rename from app-emulation/qemu/qemu-6.1.0-r2.ebuild
rename to app-emulation/qemu/qemu-6.1.0-r3.ebuild
index b91f85e5d967..8d2ca068f00d 100644
--- a/app-emulation/qemu/qemu-6.1.0-r2.ebuild
+++ b/app-emulation/qemu/qemu-6.1.0-r3.ebuild
@@ -277,6 +277,7 @@ PATCHES=(
"${FILESDIR}"/${PN}-5.2.0-disable-keymap.patch
"${FILESDIR}"/${PN}-6.0.0-make.patch
"${FILESDIR}"/${PN}-6.1.0-strings.patch
+ "${FILESDIR}"/${P}-fix-unix-socket-copy.patch
"${FILESDIR}"/${P}-automagic-libbpf.patch
"${FILESDIR}"/${P}-data-corruption.patch
)
next reply other threads:[~2021-12-21 23:53 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-21 23:53 John Helmert III [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-04-29 2:38 [gentoo-commits] repo/gentoo:master commit in: app-emulation/qemu/files/, app-emulation/qemu/ Sam James
2023-07-02 23:35 Sam James
2023-07-02 23:01 Sam James
2023-05-18 21:07 Matthias Maier
2023-05-05 18:11 Matthias Maier
2023-02-21 6:50 Sam James
2023-02-04 16:46 Andreas K. Hüttel
2022-12-08 1:22 John Helmert III
2022-11-12 19:43 Andreas K. Hüttel
2022-09-27 17:31 John Helmert III
2022-08-03 18:21 Sam James
2022-07-05 1:05 WANG Xuerui
2022-06-04 3:01 Sam James
2022-05-22 15:59 John Helmert III
2022-03-29 5:38 Sam James
2022-01-01 1:22 John Helmert III
2021-06-26 19:59 Sergei Trofimovich
2021-04-12 19:39 Sergei Trofimovich
2021-02-28 23:24 Sergei Trofimovich
2020-12-12 23:53 Sergei Trofimovich
2020-12-12 8:33 Sergei Trofimovich
2020-12-10 15:03 Sergei Trofimovich
2020-10-21 20:55 Sergei Trofimovich
2020-09-08 7:33 Sergei Trofimovich
2020-04-24 19:59 Sergei Trofimovich
2020-04-16 22:16 Sergei Trofimovich
2019-05-21 3:53 Matthias Maier
2019-05-17 8:58 Matthias Maier
2019-05-17 7:43 Matthias Maier
2019-04-29 6:48 Matthias Maier
2019-02-19 0:19 Matthias Maier
2018-08-19 17:49 Matthias Maier
2018-06-15 14:10 Jason Donenfeld
2018-03-27 15:44 Matthias Maier
2018-03-18 20:02 Matthias Maier
2017-11-12 20:22 Matthias Maier
2017-07-26 17:15 Matthias Maier
2017-05-18 4:20 Matthias Maier
2017-04-25 13:51 Matthias Maier
2017-03-27 4:03 Matthias Maier
2017-02-13 4:58 Matthias Maier
2016-12-29 18:47 Mike Frysinger
2016-11-12 17:29 Matthias Maier
2016-09-27 2:17 Matthias Maier
2016-09-09 5:23 Matthias Maier
2016-09-05 16:45 Matthias Maier
2016-09-05 5:30 Matthias Maier
2016-08-07 14:04 Luca Barbato
2016-06-07 3:02 Mike Frysinger
2016-05-17 4:41 Mike Frysinger
2016-04-23 20:30 Mike Frysinger
2016-03-23 5:25 Mike Frysinger
2015-12-15 5:55 Mike Frysinger
2015-12-08 3:17 Mike Frysinger
2015-11-23 0:41 Mike Frysinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1640130137.0ad99be8a35aff4afc249dd3b596b2eed6b5c884.ajak@gentoo \
--to=ajak@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox