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

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