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

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