[Devel] [PATCH RHEL9 COMMIT] drivers/vhost: Don't panic on double flush of a virtqueue

Konstantin Khorenko khorenko at virtuozzo.com
Thu Sep 22 14:52:58 MSK 2022


The commit is pushed to "branch-rh9-5.14.0-70.22.1.vz9.17.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh9-5.14.0-70.22.1.vz9.17.5
------>
commit dde9d64f5e1097cd178e166817ce96b252724c50
Author: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
Date:   Wed Sep 21 20:30:27 2022 +0300

    drivers/vhost: Don't panic on double flush of a virtqueue
    
    vhost_net_release() calls vhost_net_flush() after vhost_dev_cleanup(),
    trying to flush already flushed vhost_worker.
    
    vhost_net_release()
     vhost_dev_cleanup()
      vhost_cleanup_workers()
       vhost_worker_reset()
        w->worker = NULL;   // !!!
     vhost_net_flush()
      vhost_net_flush_vq()
       vhost_poll_flush()
        vhost_work_flush_vq()
         if (!w)            // w != NULL, but w->worker == NULL
            return;
         vhost_worker_flush(w)
          vhost_work_queue_at_worker(w)
           wake_up_process(w->worker)       // crash
    
    https://jira.sw.ru/browse/PSBM-142058
    
    Fixes: f45287479ce4 ("drivers/vhost: add API to queue work at virtqueue
    worker")
    
    Signed-off-by: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
    Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
 drivers/vhost/vhost.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index cac369ca6f0c..6f40018adda5 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -284,7 +284,7 @@ void vhost_work_flush_vq(struct vhost_virtqueue *vq)
 {
 	struct vhost_worker *w = READ_ONCE(vq->worker);
 
-	if (!w)
+	if (!w || !w->worker)
 		return;
 
 	vhost_worker_flush(w);


More information about the Devel mailing list