Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3396673pxf; Mon, 22 Mar 2021 05:36:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbaKUTYOMrGIItGPjUb79vCcOwSw6HpooXRd4tCtwkSRaSRKwBNfXSPUTGU/S1Ns6vYsHP X-Received: by 2002:a05:6402:2744:: with SMTP id z4mr25697057edd.347.1616416606551; Mon, 22 Mar 2021 05:36:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616416606; cv=none; d=google.com; s=arc-20160816; b=t7roKtTeRYPf6AnjmeCllIXm9nfIsbcTub0DrW7TM1HVA5LbxxEmiBTAurNUbqFSlQ ycfYSEexkE9iOFysjdzQccr/qok1pAvEK0KAetN4TgnNdY4jo79hGNCw8R9zMLLW0J/k Xk3Wo0wVG794AnXrFVWzptA5YOB0HWSosDVcNRVRySmE4RpMcCGUK2PbPULLV5nRxeg8 STC8P1ZR56PpQhzFRx9Zu9jjrr5ZjIiIDi2pd4AB+WU23AqrHcp8tOxvQg60ApijTesn mAtoqrXVgph+17E8JSrZLpBTsIvA2Q+xYFDTN6Zw2RmFnF1Ej7SO3xdssSB1bXLEecei qH2g== 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=h9DzD7Lm0wXG3RYdFix4GTi90YOzI2C85jtCKhRp3zM=; b=RnLOG758ltsaQhpW+jXEXvRZ8qEitYhuCG4iTBMEg1U4b5lXOyNsGfd7oepQitVN2o gFHfDB6ityYPQ1vuCkQ2TOxiXcD1HgCxBPewCOuIGImAufa9XmbUg+nge5E24TZv0+iM Apry4QQTJidsXDh2zdXhjwJWOpgwdqMMFUWD+R+oXbfYzonsLi3J9RjZAr7VzRYBH0v+ 5VjoG08ki7d3M9rjfF8HvDANEcjE8CPPU0H77R+XEO7/wCX2ad4e3H871Bod7qVohgge JpxbQ1u3Oca1yDmH7PMEbJuP6q12JdgFgcbeWpktdYp5O1/vjrnyOTpBbOTXTGd638w2 safQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FXA49x9p; 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 r7si11248229edt.237.2021.03.22.05.36.24; Mon, 22 Mar 2021 05:36:46 -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=FXA49x9p; 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 S231580AbhCVMdc (ORCPT + 99 others); Mon, 22 Mar 2021 08:33:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:54238 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231299AbhCVMbf (ORCPT ); Mon, 22 Mar 2021 08:31:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DADA2619A8; Mon, 22 Mar 2021 12:31:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1616416295; bh=ejwbeehcbsg5J+1zLmhrtDCxcqjFz5xG6qEf599DLOk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FXA49x9pKjuxJrl9IyA2QgG9hitopNdkcWwEB/PXfWafMEIYx/Gw6B1wFOeYeiDaA F5GCn3WVHTMpohpHaJcRh1GeDJiiOPoC2h6ymaOX4d+X5EcRqANHbwwUOoFTU4wFKU 733f2Lx18xMynw8DMPJa9f93vcF8pwAkYCQP2slE= 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.11 052/120] vhost_vdpa: fix the missing irq_bypass_unregister_producer() invocation Date: Mon, 22 Mar 2021 13:27:15 +0100 Message-Id: <20210322121931.421888960@linuxfoundation.org> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210322121929.669628946@linuxfoundation.org> References: <20210322121929.669628946@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 @@ -906,14 +906,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)