|
|
9ae3a8 |
From 18c4fbe13ce03654f763f6569bb740c57109555c Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Eric Blake <eblake@redhat.com>
|
|
|
9ae3a8 |
Date: Mon, 10 Jul 2017 17:52:18 +0200
|
|
|
9ae3a8 |
Subject: [PATCH] qemu-nbd: Ignore SIGPIPE
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Eric Blake <eblake@redhat.com>
|
|
|
9ae3a8 |
Message-id: <20170710175218.13682-1-eblake@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 75718
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.4.z qemu-kvm PATCH] qemu-nbd: Ignore SIGPIPE
|
|
|
9ae3a8 |
Bugzilla: 1466463
|
|
|
9ae3a8 |
RH-Acked-by: John Snow <jsnow@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
From: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
qemu proper has done so for 13 years
|
|
|
9ae3a8 |
(8a7ddc38a60648257dc0645ab4a05b33d6040063), qemu-img and qemu-io have
|
|
|
9ae3a8 |
done so for four years (526eda14a68d5b3596be715505289b541288ef2a).
|
|
|
9ae3a8 |
Ignoring this signal is especially important in qemu-nbd because
|
|
|
9ae3a8 |
otherwise a client can easily take down the qemu-nbd server by dropping
|
|
|
9ae3a8 |
the connection when the server wants to send something, for example:
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
$ qemu-nbd -x foo -f raw -t null-co:// &
|
|
|
9ae3a8 |
[1] 12726
|
|
|
9ae3a8 |
$ qemu-io -c quit nbd://localhost/bar
|
|
|
9ae3a8 |
can't open device nbd://localhost/bar: No export with name 'bar' available
|
|
|
9ae3a8 |
[1] + 12726 broken pipe qemu-nbd -x foo -f raw -t null-co://
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
In this case, the client sends an NBD_OPT_ABORT and closes the
|
|
|
9ae3a8 |
connection (because it is not required to wait for a reply), but the
|
|
|
9ae3a8 |
server replies with an NBD_REP_ACK (because it is required to reply).
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
Message-Id: <20170611123714.31292-1-mreitz@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 041e32b8d9d076980b4e35317c0339e57ab888f1)
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Conflicts:
|
|
|
9ae3a8 |
qemu-nbd.c - context
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Fixes CVE-2017-10664
|
|
|
9ae3a8 |
Signed-off-by: Eric Blake <eblake@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
qemu-nbd.c | 5 +++++
|
|
|
9ae3a8 |
1 file changed, 5 insertions(+)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/qemu-nbd.c b/qemu-nbd.c
|
|
|
9ae3a8 |
index e0f4517..fc768eb 100644
|
|
|
9ae3a8 |
--- a/qemu-nbd.c
|
|
|
9ae3a8 |
+++ b/qemu-nbd.c
|
|
|
9ae3a8 |
@@ -363,6 +363,11 @@ int main(int argc, char **argv)
|
|
|
9ae3a8 |
memset(&sa_sigterm, 0, sizeof(sa_sigterm));
|
|
|
9ae3a8 |
sa_sigterm.sa_handler = termsig_handler;
|
|
|
9ae3a8 |
sigaction(SIGTERM, &sa_sigterm, NULL);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+#ifdef CONFIG_POSIX
|
|
|
9ae3a8 |
+ signal(SIGPIPE, SIG_IGN);
|
|
|
9ae3a8 |
+#endif
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
qemu_init_exec_dir(argv[0]);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
while ((ch = getopt_long(argc, argv, sopt, lopt, &opt_ind)) != -1) {
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|