yeahuh / rpms / qemu-kvm

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