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

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