Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3401806pxf; Mon, 22 Mar 2021 05:44:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDetBOONvzvIzB08n5Bg/Fzw4ipbW/FDL27eBGZSHZ+EZvT7vaztZlHfVhZSJ0Fq4+RVhd X-Received: by 2002:a17:906:a51:: with SMTP id x17mr19245180ejf.25.1616417076210; Mon, 22 Mar 2021 05:44:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616417076; cv=none; d=google.com; s=arc-20160816; b=oqQrmPgkD1zHTNStDWJLQ0oQL80q6a1NGAxwmnkpGRJu8J/gxCHiqFC0dl8F48BQ9i DPDGKpOMwahxftT/tBY2uNypS3hw+sXcoTj0vLbP/+LjBvFjFGhavchXH+/HPArr78x+ m4yy/Fx6RBaR5qe6hjwIOqPUjwPQ0MYLrAD7GCreBBbjBpsueY6WhqtR0Wk+Q7fJfB70 mdORMmrNFqEkrW4UnKVOJvGGUFR1fdif+Bo9wAixOKukP0xcOXP28I35lr69H6UCkFF3 lOtJE3V1oNPyRdeFtxBaJBkOgVZ7S2U3lgm+F/bXknwF9i+EXtxRG3iF5Tyx5ATi8fDG kR2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=84p0iz7a3+arHb7E65/uFpuSdVRWc4c85yV969MlMoc=; b=SRMQJ3LDKbiTP9ch4V2M2ymeQm+EJWTzTUwl/FySFGreNLwz4u7JcG58LDszW7P+TE OcW3PtyHLlO8teIq6C/JxEBkEH7GVRq3i77nDQKul3/vf9jmxoQaJ90t7DGFUFD3ZAls Iou/StMtG/yVdMj+rwy7BvvttgfzhQ8krkD8YrNWxjbGWxQa3w+BYXAWIuM7l0FFKciN gVgirqPlT+SJfLgPvbkoxB+cuWEGx/YWQ5ygNuQnTz6oGTOOQnCWBx8IIMC2b2y2ifau 8b8FWBm9xoHdNMAEI2cQI2RyYsIKmMs7ZEq/dHWuZL2oPVdQf6rhEwrMns2UCgpHXh2M PuAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=G0Xy3uHO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k13si11545299edr.48.2021.03.22.05.44.13; Mon, 22 Mar 2021 05:44:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=G0Xy3uHO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232625AbhCVMmy (ORCPT + 99 others); Mon, 22 Mar 2021 08:42:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:56922 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231915AbhCVMhJ (ORCPT ); Mon, 22 Mar 2021 08:37:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F10A4619B0; Mon, 22 Mar 2021 12:36:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1616416594; bh=O4s0c9JoysGQ5mVTheWhFvVgaK+FQc/o3HURvt+AD8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G0Xy3uHO0Oyo3OIeFvYX9enN7sFxOQZWf+LYlFitZ+lb+PQOnHgngPDuzpF7HbtoF PZnM65ZobxM74K18mXv+y26lz+J5Vjgo6giv7l8JOhW6hnPNymVL6EpJ/Sz2EN3V2k Bx9i9gyb+5w6BVOc9ynHEplQz+QWQY0Yqf1KvAww= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gautam Dawar , Jason Wang , "Michael S. Tsirkin" Subject: [PATCH 5.10 047/157] vhost_vdpa: fix the missing irq_bypass_unregister_producer() invocation Date: Mon, 22 Mar 2021 13:26:44 +0100 Message-Id: <20210322121935.241064318@linuxfoundation.org> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210322121933.746237845@linuxfoundation.org> References: <20210322121933.746237845@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gautam Dawar commit 4c050286bb202cffd5467c1cba982dff391d62e1 upstream. When qemu with vhost-vdpa netdevice is run for the first time, it works well. But after the VM is powered off, the next qemu run causes kernel panic due to a NULL pointer dereference in irq_bypass_register_producer(). When the VM is powered off, vhost_vdpa_clean_irq() misses on calling irq_bypass_unregister_producer() for irq 0 because of the existing check. This leaves stale producer nodes, which are reset in vhost_vring_call_reset() when vhost_dev_init() is invoked during the second qemu run. As the node member of struct irq_bypass_producer is also initialized to zero, traversal on the producers list causes crash due to NULL pointer dereference. Fixes: 2cf1ba9a4d15c ("vhost_vdpa: implement IRQ offloading in vhost_vdpa") Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=211711 Signed-off-by: Gautam Dawar Acked-by: Jason Wang Link: https://lore.kernel.org/r/20210224114845.104173-1-gdawar.xilinx@gmail.com Signed-off-by: Michael S. Tsirkin Signed-off-by: Greg Kroah-Hartman --- drivers/vhost/vdpa.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -910,14 +910,10 @@ err: static void vhost_vdpa_clean_irq(struct vhost_vdpa *v) { - struct vhost_virtqueue *vq; int i; - for (i = 0; i < v->nvqs; i++) { - vq = &v->vqs[i]; - if (vq->call_ctx.producer.irq) - irq_bypass_unregister_producer(&vq->call_ctx.producer); - } + for (i = 0; i < v->nvqs; i++) + vhost_vdpa_unsetup_vq_irq(v, i); } static int vhost_vdpa_release(struct inode *inode, struct file *filep)