yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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