thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-pr-manager-helper-avoid-SIGSEGV-when-writing-to-the-.patch

26ba25
From 3f937c82256585da1abba44c4600b96b0b186df4 Mon Sep 17 00:00:00 2001
26ba25
From: Paolo Bonzini <pbonzini@redhat.com>
26ba25
Date: Fri, 6 Jul 2018 17:56:53 +0200
26ba25
Subject: [PATCH 193/268] pr-manager-helper: avoid SIGSEGV when writing to the
26ba25
 socket fail
26ba25
26ba25
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
26ba25
Message-id: <20180706175659.30615-4-pbonzini@redhat.com>
26ba25
Patchwork-id: 81245
26ba25
O-Subject: [RHEL7.6 qemu-kvm-rhev PATCH 3/9] pr-manager-helper: avoid SIGSEGV when writing to the socket fail
26ba25
Bugzilla: 1533158
26ba25
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
26ba25
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
26ba25
RH-Acked-by: Michal Privoznik <mprivozn@redhat.com>
26ba25
26ba25
When writing to the qemu-pr-helper socket failed, the persistent
26ba25
reservation manager was correctly disconnecting the socket, but it
26ba25
did not clear pr_mgr->ioc.  So the rest of the code did not know
26ba25
that the socket had been disconnected, accessed pr_mgr->ioc and
26ba25
happily caused a crash.
26ba25
26ba25
To reproduce, it is enough to stop qemu-pr-helper between QEMU
26ba25
startup and executing e.g. sg_persist -k /dev/sdb.
26ba25
26ba25
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
26ba25
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
26ba25
(cherry picked from commit aad10040d411d21542dc9ae58a2854c89ccedd78)
26ba25
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
26ba25
---
26ba25
 scsi/pr-manager-helper.c | 1 +
26ba25
 1 file changed, 1 insertion(+)
26ba25
26ba25
diff --git a/scsi/pr-manager-helper.c b/scsi/pr-manager-helper.c
26ba25
index 82ff6b6..0c0fe38 100644
26ba25
--- a/scsi/pr-manager-helper.c
26ba25
+++ b/scsi/pr-manager-helper.c
26ba25
@@ -71,6 +71,7 @@ static int pr_manager_helper_write(PRManagerHelper *pr_mgr,
26ba25
         if (n_written <= 0) {
26ba25
             assert(n_written != QIO_CHANNEL_ERR_BLOCK);
26ba25
             object_unref(OBJECT(pr_mgr->ioc));
26ba25
+            pr_mgr->ioc = NULL;
26ba25
             return n_written < 0 ? -EINVAL : 0;
26ba25
         }
26ba25
 
26ba25
-- 
26ba25
1.8.3.1
26ba25