[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 1/3] scsi: protect req->aiocb with AioContext lock
From: |
Eric Blake |
Subject: |
Re: [PATCH v2 1/3] scsi: protect req->aiocb with AioContext lock |
Date: |
Wed, 15 Feb 2023 12:17:17 -0600 |
User-agent: |
NeoMutt/20220429 |
On Fri, Feb 10, 2023 at 09:32:36AM -0500, Stefan Hajnoczi wrote:
> If requests are being processed in the IOThread when a SCSIDevice is
> unplugged, scsi_device_purge_requests() -> scsi_req_cancel_async() races
> with I/O completion callbacks. Both threads load and store req->aiocb.
> This can lead to assert(r->req.aiocb == NULL) failures and undefined
> behavior.
>
> Protect r->req.aiocb with the AioContext lock to prevent the race.
I understand that we're trying to get rid of this lock down the road,
but until then, properly using it to guard things is appropriate.
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org