Blame SOURCES/kvm-Migration-TLS-Fix-crash-due-to-double-cleanup.patch

383d26
From c70d2938f2acf89ca872061086f1fe26e6c5a69d Mon Sep 17 00:00:00 2001
383d26
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
383d26
Date: Fri, 22 Jun 2018 19:00:01 +0200
383d26
Subject: [PATCH 22/57] Migration+TLS: Fix crash due to double cleanup
383d26
MIME-Version: 1.0
383d26
Content-Type: text/plain; charset=UTF-8
383d26
Content-Transfer-Encoding: 8bit
383d26
383d26
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
383d26
Message-id: <20180622190005.21297-15-dgilbert@redhat.com>
383d26
Patchwork-id: 81004
383d26
O-Subject: [RHEL7.6 qemu-kvm-rhev PATCH 14/18] Migration+TLS: Fix crash due to double cleanup
383d26
Bugzilla: 1584139
383d26
RH-Acked-by: Juan Quintela <quintela@redhat.com>
383d26
RH-Acked-by: Peter Xu <peterx@redhat.com>
383d26
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
383d26
383d26
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
383d26
383d26
During a TLS connect we see:
383d26
  migration_channel_connect calls
383d26
  migration_tls_channel_connect
383d26
  (calls after TLS setup)
383d26
  migration_channel_connect
383d26
383d26
My previous error handling fix made migration_channel_connect
383d26
call migrate_fd_connect in all cases; unfortunately the above
383d26
means it gets called twice and crashes doing double cleanup.
383d26
383d26
Fixes: 688a3dcba98
383d26
383d26
Reported-by: Peter Krempa <pkrempa@redhat.com>
383d26
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
383d26
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
383d26
Message-Id: <20180430185943.35714-1-dgilbert@redhat.com>
383d26
Signed-off-by: Juan Quintela <quintela@redhat.com>
383d26
(cherry picked from commit 8b7bf2badac25c0a52aff1b181ad75fdb304dd0c)
383d26
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
383d26
---
383d26
 migration/channel.c | 9 +++++++++
383d26
 1 file changed, 9 insertions(+)
383d26
383d26
diff --git a/migration/channel.c b/migration/channel.c
383d26
index c5eaf0f..7a32b5a 100644
383d26
--- a/migration/channel.c
383d26
+++ b/migration/channel.c
383d26
@@ -71,6 +71,15 @@ void migration_channel_connect(MigrationState *s,
383d26
             !object_dynamic_cast(OBJECT(ioc),
383d26
                                  TYPE_QIO_CHANNEL_TLS)) {
383d26
             migration_tls_channel_connect(s, ioc, hostname, &error);
383d26
+
383d26
+            if (!error) {
383d26
+                /* tls_channel_connect will call back to this
383d26
+                 * function after the TLS handshake,
383d26
+                 * so we mustn't call migrate_fd_connect until then
383d26
+                 */
383d26
+
383d26
+                return;
383d26
+            }
383d26
         } else {
383d26
             QEMUFile *f = qemu_fopen_channel_output(ioc);
383d26
 
383d26
-- 
383d26
1.8.3.1
383d26