[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/5] vhost-user-blk: Don't reconnect during initialisation
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [PATCH 1/5] vhost-user-blk: Don't reconnect during initialisation |
Date: |
Wed, 28 Apr 2021 21:37:32 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 |
On 4/22/21 7:02 PM, Kevin Wolf wrote:
> This is a partial revert of commits 77542d43149 and bc79c87bcde.
>
> Usually, an error during initialisation means that the configuration was
> wrong. Reconnecting won't make the error go away, but just turn the
> error condition into an endless loop. Avoid this and return errors
> again.
>
> Additionally, calling vhost_user_blk_disconnect() from the chardev event
> handler could result in use-after-free because none of the
> initialisation code expects that the device could just go away in the
TIL initialisation wording.
> middle. So removing the call fixes crashes in several places.
>
> For example, using a num-queues setting that is incompatible with the
> backend would result in a crash like this (dereferencing dev->opaque,
> which is already NULL):
>
> #0 0x0000555555d0a4bd in vhost_user_read_cb (source=0x5555568f4690,
> condition=(G_IO_IN | G_IO_HUP), opaque=0x7fffffffcbf0) at
> ../hw/virtio/vhost-user.c:313
> #1 0x0000555555d950d3 in qio_channel_fd_source_dispatch
> (source=0x555557c3f750, callback=0x555555d0a478 <vhost_user_read_cb>,
> user_data=0x7fffffffcbf0) at ../io/channel-watch.c:84
> #2 0x00007ffff7b32a9f in g_main_context_dispatch () at
> /lib64/libglib-2.0.so.0
> #3 0x00007ffff7b84a98 in g_main_context_iterate.constprop () at
> /lib64/libglib-2.0.so.0
> #4 0x00007ffff7b32163 in g_main_loop_run () at /lib64/libglib-2.0.so.0
> #5 0x0000555555d0a724 in vhost_user_read (dev=0x555557bc62f8,
> msg=0x7fffffffcc50) at ../hw/virtio/vhost-user.c:402
> #6 0x0000555555d0ee6b in vhost_user_get_config (dev=0x555557bc62f8,
> config=0x555557bc62ac "", config_len=60) at ../hw/virtio/vhost-user.c:2133
> #7 0x0000555555d56d46 in vhost_dev_get_config (hdev=0x555557bc62f8,
> config=0x555557bc62ac "", config_len=60) at ../hw/virtio/vhost.c:1566
> #8 0x0000555555cdd150 in vhost_user_blk_device_realize (dev=0x555557bc60b0,
> errp=0x7fffffffcf90) at ../hw/block/vhost-user-blk.c:510
> #9 0x0000555555d08f6d in virtio_device_realize (dev=0x555557bc60b0,
> errp=0x7fffffffcff0) at ../hw/virtio/virtio.c:3660
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
> hw/block/vhost-user-blk.c | 54 ++++++++++-----------------------------
> 1 file changed, 13 insertions(+), 41 deletions(-)
[PATCH 5/5] vhost-user-blk: Check that num-queues is supported by backend, Kevin Wolf, 2021/04/22
[PATCH 4/5] virtio: Fail if iommu_platform is requested, but unsupported, Kevin Wolf, 2021/04/22