Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp3287989pxb; Mon, 18 Apr 2022 21:54:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwd7THllRXR0fOA4UVpx6tsl/0Je2/7t+MYaDZKjskDa48Mxh96cZBxkfmW5uMS91D3W53Y X-Received: by 2002:a17:907:160f:b0:6ee:8214:3cee with SMTP id hb15-20020a170907160f00b006ee82143ceemr11687734ejc.433.1650344088135; Mon, 18 Apr 2022 21:54:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650344088; cv=none; d=google.com; s=arc-20160816; b=YKb6q/Vym1M0VxA6dNFVJ7JG7r9SvYEEkCiuGQBlGAZ6Pglm6bWPz06bfrc1EVjvA2 ffdEPw+tUWUmvqsGMMl5ehYdhiaGoeTnqFX/NCcmThhJIAlf8rA0jaY/7nrU7wITZJ72 Bfp24VvHWy+TQSkhX2IR/xwSrLPeE8Hs7zgN3ocfnhGNFj/LqQXbFJ7sODcZwZPtSezj IscVnabTr8vJUvwNDSXskak48ki/cusUUOlQn7F+m2i3muzJljwcTbAZlFZrFK6n88/c LTmTj65k/7yNjaxyoWrkU7alSW/VYYn/o3Ka70gD4lIAynzEPIPawxUXAcFdBj8PPbqx 30dw== 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=tuKlRuS6pb+o/R4QhmJXpxlhSSkwMm/LiuYa96+wNjo=; b=I7zKL0dVjQ3RU3PeTd9TP9Z4n/ygts3Pk+8qu2xdNejs2mDBALd8aTDltoGR1VXyD4 rvoTHUL7Lwn1Pgfyw31Hw/lRteaqflsTrVTtvjlrDnfR5OEKK4l2F8mK+gqD/CghNuGt 1V1RdAWfElAR3DpxrRHb99joiUkiyKq0gKK4nbbWjQ2k/12QqbjPyDf6gGpdQFSLatN/ oNQSZ37ElEBCsRJXEFL512HAfYgzEPwb/Mwv8b9feZbOaGN2l5oCivxTPpeO/iH6QT74 C/iRNo+6RxqHkPvuXbNXBwbr1rLiuuiPGU0jcv43eU6flgmm48XZdjLKLP6mYt24rmbS jkeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=B0QQvd1F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h12-20020a056402280c00b00418c2b5bdecsi9151910ede.206.2022.04.18.21.54.24; Mon, 18 Apr 2022 21:54:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=B0QQvd1F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S242459AbiDRNfT (ORCPT + 99 others); Mon, 18 Apr 2022 09:35:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242736AbiDRNJZ (ORCPT ); Mon, 18 Apr 2022 09:09:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA75536333; Mon, 18 Apr 2022 05:48:56 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D404F6124A; Mon, 18 Apr 2022 12:48:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD619C385A1; Mon, 18 Apr 2022 12:48:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650286131; bh=pbmnvJMpAqebIetUAqMQen3WmrQy0z43KJeIZmjeLA8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B0QQvd1Fu7t/wWCaQZstufk384vwW7hIvovbYzCAfvABSRnIO6UXBq/XV9JgHI+Qi FhXqyQlwDnoVrf5dJPQ8jsJk+AW43pIrqzGXyCqVnlU7dItWBcwVCewW9f1Ea6dzYb uxEwJABpZqJk0OUR/CwwFg3MdaAmhMDEEG8jb7Gg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Michael S. Tsirkin" , Sasha Levin Subject: [PATCH 4.14 004/284] virtio_console: break out of buf poll on remove Date: Mon, 18 Apr 2022 14:09:45 +0200 Message-Id: <20220418121210.819571886@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121210.689577360@linuxfoundation.org> References: <20220418121210.689577360@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michael S. Tsirkin [ Upstream commit 0e7174b9d5877130fec41fb4a16e0c2ee4958d44 ] A common pattern for device reset is currently: vdev->config->reset(vdev); .. cleanup .. reset prevents new interrupts from arriving and waits for interrupt handlers to finish. However if - as is common - the handler queues a work request which is flushed during the cleanup stage, we have code adding buffers / trying to get buffers while device is reset. Not good. This was reproduced by running modprobe virtio_console modprobe -r virtio_console in a loop. Fix this up by calling virtio_break_device + flush before reset. Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1786239 Signed-off-by: Michael S. Tsirkin Signed-off-by: Sasha Levin --- drivers/char/virtio_console.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index 0fb3a8e62e62..2140d401523f 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c @@ -2001,6 +2001,13 @@ static void virtcons_remove(struct virtio_device *vdev) list_del(&portdev->list); spin_unlock_irq(&pdrvdata_lock); + /* Device is going away, exit any polling for buffers */ + virtio_break_device(vdev); + if (use_multiport(portdev)) + flush_work(&portdev->control_work); + else + flush_work(&portdev->config_work); + /* Disable interrupts for vqs */ vdev->config->reset(vdev); /* Finish up work that's lined up */ -- 2.34.1