thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-block-nbd-Assert-there-are-no-timers-when-closed.patch

60061b
From d5a85fcf996948d1154e88e9ee3b4e8c64ec2694 Mon Sep 17 00:00:00 2001
60061b
From: Hanna Reitz <hreitz@redhat.com>
60061b
Date: Fri, 4 Feb 2022 12:10:08 +0100
60061b
Subject: [PATCH 2/6] block/nbd: Assert there are no timers when closed
60061b
60061b
RH-Author: Hanna Reitz <hreitz@redhat.com>
60061b
RH-MergeRequest: 117: block/nbd: Handle AioContext changes
60061b
RH-Commit: [2/6] 995795ae9844a7d2b28cb1e57fd7fe81482d0205
60061b
RH-Bugzilla: 2035185
60061b
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
60061b
RH-Acked-by: Eric Blake <eblake@redhat.com>
60061b
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
60061b
60061b
Our two timers must not remain armed beyond nbd_clear_bdrvstate(), or
60061b
they will access freed data when they fire.
60061b
60061b
This patch is separate from the patches that actually fix the issue
60061b
(HEAD^^ and HEAD^) so that you can run the associated regression iotest
60061b
(281) on a configuration that reproducibly exposes the bug.
60061b
60061b
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
60061b
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
60061b
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
60061b
(cherry picked from commit 8a39c381e5e407d2fe5500324323f90a8540fa90)
60061b
60061b
Conflict:
60061b
- block/nbd.c: open_timer was introduced after the 6.2 release (for
60061b
  nbd's @open-timeout parameter), and has not been backported, so drop
60061b
  the assertion that it is NULL
60061b
60061b
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
60061b
---
60061b
 block/nbd.c | 3 +++
60061b
 1 file changed, 3 insertions(+)
60061b
60061b
diff --git a/block/nbd.c b/block/nbd.c
60061b
index b8e5a9b4cc..aab20125d8 100644
60061b
--- a/block/nbd.c
60061b
+++ b/block/nbd.c
60061b
@@ -108,6 +108,9 @@ static void nbd_clear_bdrvstate(BlockDriverState *bs)
60061b
 
60061b
     yank_unregister_instance(BLOCKDEV_YANK_INSTANCE(bs->node_name));
60061b
 
60061b
+    /* Must not leave timers behind that would access freed data */
60061b
+    assert(!s->reconnect_delay_timer);
60061b
+
60061b
     object_unref(OBJECT(s->tlscreds));
60061b
     qapi_free_SocketAddress(s->saddr);
60061b
     s->saddr = NULL;
60061b
-- 
60061b
2.27.0
60061b