From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796384313; b=wwCzbhMJjh/fhBTzyPHLwHa7dQ8PKdW0i35d4dSyAjnDDIjPs3Z9v7lrsuVZ/kAr/5jw UuB/xn2swecHbKfSMYx/2mknYP0+nCTS53XY2yAKfouE5kcN06Sk1/fnnRPE5PzaWtEHa z9iqUeEEh+Oj8Dhn2ooo97gdYPmpoBHRHOurat7l8qbaUpDY8NHQz2Wp9peQRTgC4KpOj MyQROWJWvPIqiIPWirQA8OQH/IyHODE4qolyvBVo4lt50DB4HUI5g40BZcedn2vLzKz8O YSGhKZ8aqEtqUn9hlXOl7Tv6hWXDaOmv/HcRIfMWDKb6UpMzjd7j8MZ8ES5tnufhUKQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384313; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=Dsmm17ZuOYIMcPb/9g9hir9YbQMIbKIZqUyGxeQYq00=; b=QhdlgvXEwMiq6lJMzHVWcsbvTCfTQg36rENMUnbx7XZoqUH8rlZ5BvqeC3STKtBv8b7z k/Y3QvofOeE32gzCy6JrlDjbmX8ZrIDG8FVVW9pSWiKHNI3VsPWSyL2MlTc+25zxuiHdS BaMMoNrux7JPYUqKlGIXRiRBpRF15HEQC1dEbJ9a2tHROsLYygGdJatNqGjX4C4Og0G4f RtwrvltVCbWSSfyZ/xYdh/e9F7qvc1NgTgEalHSh/IqyiFEt3dTGGU3uw4hfdr7Q1AEsu XVxeDWU+XxIxh8x7tU23vtBEQTafp3+wzxEbZrgCc4ofGTRi1TttK2gIHMAfZsmwIPA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b="mtblO/xj"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C6BD606A32D; Fri, 4 Dec 2026 11:38:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=mtblO/xj Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67F791F000C2; Fri, 4 Dec 2026 11:38:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384312; bh=Dsmm17ZuOYIMcPb/9g9hir9YbQMIbKIZqUyGxeQYq00=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=mtblO/xjw0WPCKRL4D25T6HSqMDyhU/4Vhbyy9T+MjdON99w8ATgymWOv18Em/nWh g2LEVCzUDGjAsiWY30V65yu8U/h0ZQTtVOm0QgR/iNpVLsYqkBVaB+WmoRhbJFHQAk +WtKM5S2+61/LH2ua4aJ18pdMKJMf4H00HVY8V6I= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jia Jia , Mike Christie , "Michael S. Tsirkin" , Sasha Levin Subject: [PATCH 6.6 0097/1167] vhost-scsi: do not relock event vq mutex on send_evt fallback Date: Fri, 4 Dec 2026 18:52:04 +0900 Message-ID: <20261204100704.623543261@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jia Jia [ Upstream commit a016d03a9cfe29aeeba438f32f8e8f63291e3275 ] vhost_scsi_send_evt() is called with the event virtqueue mutex held. If the worker is gone, the fallback currently calls vhost_scsi_complete_events(), which tries to acquire the same mutex again and deadlocks the caller. Split event completion into a helper for callers that already hold the mutex and a locking wrapper for the event worker. Use the helper on the fallback path. Link: https://lore.kernel.org/all/20260905005352.1E5B01F00A3D@smtp.kernel.org/ Fixes: b1b2ce58ed23 ("vhost-scsi: Handle vhost_vq_work_queue failures for events") Signed-off-by: Jia Jia Reviewed-by: Mike Christie Signed-off-by: Michael S. Tsirkin Message-ID: <20260915094244.7900-3-physicalmtea@gmail.com> Signed-off-by: Sasha Levin --- drivers/vhost/scsi.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index 48c1a2518466e..a0d407c49694b 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c @@ -497,19 +497,26 @@ vhost_scsi_do_evt_work(struct vhost_scsi *vs, struct vhost_scsi_evt *evt) vq_err(vq, "Faulted on vhost_scsi_send_event\n"); } -static void vhost_scsi_complete_events(struct vhost_scsi *vs, bool drop) +/* Caller must hold the event virtqueue mutex. */ +static void __vhost_scsi_complete_events(struct vhost_scsi *vs, bool drop) { - struct vhost_virtqueue *vq = &vs->vqs[VHOST_SCSI_VQ_EVT].vq; struct vhost_scsi_evt *evt, *t; struct llist_node *llnode; - mutex_lock(&vq->mutex); llnode = llist_reverse_order(llist_del_all(&vs->vs_event_list)); llist_for_each_entry_safe(evt, t, llnode, list) { if (!drop) vhost_scsi_do_evt_work(vs, evt); vhost_scsi_free_evt(vs, evt); } +} + +static void vhost_scsi_complete_events(struct vhost_scsi *vs, bool drop) +{ + struct vhost_virtqueue *vq = &vs->vqs[VHOST_SCSI_VQ_EVT].vq; + + mutex_lock(&vq->mutex); + __vhost_scsi_complete_events(vs, drop); mutex_unlock(&vq->mutex); } @@ -1532,7 +1539,7 @@ vhost_scsi_send_evt(struct vhost_scsi *vs, struct vhost_virtqueue *vq, llist_add(&evt->list, &vs->vs_event_list); if (!vhost_vq_work_queue(vq, &vs->vs_event_work)) - vhost_scsi_complete_events(vs, true); + __vhost_scsi_complete_events(vs, true); } static void vhost_scsi_evt_handle_kick(struct vhost_work *work) -- 2.53.0