From 02bd2b755adbddeb71dd721eafaff2f48554a9ea Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Mon, 10 Jul 2017 16:28:19 +0200 Subject: [PATCH 2/2] qemu-nbd: Ignore SIGPIPE RH-Author: Eric Blake Message-id: <20170710162819.24843-1-eblake@redhat.com> Patchwork-id: 75717 O-Subject: [RHEV-7.4.z qemu-kvm-rhev PATCH] qemu-nbd: Ignore SIGPIPE Bugzilla: 1468108 RH-Acked-by: John Snow RH-Acked-by: Stefan Hajnoczi RH-Acked-by: Miroslav Rezanina From: Max Reitz qemu proper has done so for 13 years (8a7ddc38a60648257dc0645ab4a05b33d6040063), qemu-img and qemu-io have done so for four years (526eda14a68d5b3596be715505289b541288ef2a). Ignoring this signal is especially important in qemu-nbd because otherwise a client can easily take down the qemu-nbd server by dropping the connection when the server wants to send something, for example: $ qemu-nbd -x foo -f raw -t null-co:// & [1] 12726 $ qemu-io -c quit nbd://localhost/bar can't open device nbd://localhost/bar: No export with name 'bar' available [1] + 12726 broken pipe qemu-nbd -x foo -f raw -t null-co:// In this case, the client sends an NBD_OPT_ABORT and closes the connection (because it is not required to wait for a reply), but the server replies with an NBD_REP_ACK (because it is required to reply). Signed-off-by: Max Reitz Message-Id: <20170611123714.31292-1-mreitz@redhat.com> Signed-off-by: Paolo Bonzini (cherry picked from commit 041e32b8d9d076980b4e35317c0339e57ab888f1) Fixes CVE-2017-10664 Signed-off-by: Eric Blake Signed-off-by: Miroslav Rezanina --- qemu-nbd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qemu-nbd.c b/qemu-nbd.c index 483dd77..5deb37e 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -581,6 +581,10 @@ int main(int argc, char **argv) sa_sigterm.sa_handler = termsig_handler; sigaction(SIGTERM, &sa_sigterm, NULL); +#ifdef CONFIG_POSIX + signal(SIGPIPE, SIG_IGN); +#endif + module_call_init(MODULE_INIT_TRACE); qcrypto_init(&error_fatal); -- 1.8.3.1