]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
vhost scsi: fix cmd completion race
authorMike Christie <michael.christie@oracle.com>
Tue, 10 Nov 2020 05:33:21 +0000 (23:33 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 2 Dec 2020 07:49:48 +0000 (08:49 +0100)
commit8a2ae7fa5d5c5ded438aad3235d4c1a12ecf2d2f
tree4fcba82f8679bea6f1865989caacad520f6f67da
parent4940816604e3ce7e05e8df297773ee86c0476d48
vhost scsi: fix cmd completion race

[ Upstream commit 47a3565e8bb14ec48a75b48daf57aa830e2691f8 ]

We might not do the final se_cmd put from vhost_scsi_complete_cmd_work.
When the last put happens a little later then we could race where
vhost_scsi_complete_cmd_work does vhost_signal, the guest runs and sends
more IO, and vhost_scsi_handle_vq runs but does not find any free cmds.

This patch has us delay completing the cmd until the last lio core ref
is dropped. We then know that once we signal to the guest that the cmd
is completed that if it queues a new command it will find a free cmd.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
Reviewed-by: Maurizio Lombardi <mlombard@redhat.com>
Link: https://lore.kernel.org/r/1604986403-4931-4-git-send-email-michael.christie@oracle.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/vhost/scsi.c