Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp2461284imd; Fri, 2 Nov 2018 11:48:46 -0700 (PDT) X-Google-Smtp-Source: AJdET5eZ+JHg2+gHuGM86/0SAYkQOD8VTH0FLr/N89OBlRTHEIKhn1hQTuM5t2tXZxRdclwKh+Wc X-Received: by 2002:a17:902:503:: with SMTP id 3-v6mr12261345plf.252.1541184526001; Fri, 02 Nov 2018 11:48:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541184525; cv=none; d=google.com; s=arc-20160816; b=ODnZYMdN/JNeT+/px0ngfaLM87ZPxKWpDqPTCxdDp2ZXphKau5l7NcKfDUdtd80GIq MRWwQapcCa8y5CYCBSUmIirTnavEyIwNJ1PPPxW7aGfYbbjOsMglOkTSvgC4lHmAOpbQ hCiUq8W523BQcX9lREac3WCvZkn73K2ZE4IepNQv1PN/+QVcUcHfwJBlAicVMFcMi4bO yj+kwtoArHE7y3EBibi6JvO1JRE4kAgWxtbG8TD/6xCj/w4w+IyIQjPc20RFo3o9hM++ 3RmaqjxrnfzaZzW8MBAICsNRPOHSEq12e7IRA72MixmTniGhuFbp9DLK/VgX3ILNN6Sq uFbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zmtw2ErvmXSWWeYz3I52HKg2aVocxxkkvqP3zGSOeW4=; b=LwoN4CoAjv24njOfdgXLDis8gXVXzK6Y2ZBhDZkVfpecKtkBRYMAL+Qks4zkNMG1wB HbTfGWehBF1vHIpDV4ZGTaIlOdJgzIqhOH8YHXIXVtnGW0fiKRbrPuRnoWFlTckFSiUc io4qpsp7DiAeYIOtGN+O1LrE7KgwIGFbyzx17slX1ERPhu7YsWA0myR6RcJMYBJtNpR4 BDYU2yfkDxOGYfSWNQVaMtQ22LQC3CoLWtOTC735dTyEWBSpd7W69GYjtYoVNTKxqbGF o/rqjTgskH9+6GJyuEwbFeMzLqpqQW56DdhvAV/h4sF6RoZ//5PcKKbpBJX4aWW5fsmt KmPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zainsS3H; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 98-v6si1540938pla.312.2018.11.02.11.48.31; Fri, 02 Nov 2018 11:48:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zainsS3H; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730388AbeKCDyj (ORCPT + 99 others); Fri, 2 Nov 2018 23:54:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:50614 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729136AbeKCDyj (ORCPT ); Fri, 2 Nov 2018 23:54:39 -0400 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D356F20837; Fri, 2 Nov 2018 18:46:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541184385; bh=yz689L0jE42DIUvEchb1Az4F9bCCKOpUhbibQoGCE/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zainsS3Hf32oiLttWS+ffN1Jw7RiR56kcxgBRK9ZKtsjfP5oXAGsJ1K9xlI6WZ3db Sdc/5WcSiW9kjay1vUJzLRG/mhIMjfzvju9Zqsk1k+E39VcAdkMyhrfz0Jnbepn8Uz H7sCUPLKufilTqrAJyere1yAvZU4JdZgZ8lgexJk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ake Koomsin , Jason Wang , "Michael S. Tsirkin" , "David S. Miller" Subject: [PATCH 4.18 121/150] virtio_net: avoid using netif_tx_disable() for serializing tx routine Date: Fri, 2 Nov 2018 19:34:43 +0100 Message-Id: <20181102182911.402342725@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181102182902.250560510@linuxfoundation.org> References: <20181102182902.250560510@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ake Koomsin [ Upstream commit 05c998b738fdd3e5d6a257bcacc8f34b6284d795 ] Commit 713a98d90c5e ("virtio-net: serialize tx routine during reset") introduces netif_tx_disable() after netif_device_detach() in order to avoid use-after-free of tx queues. However, there are two issues. 1) Its operation is redundant with netif_device_detach() in case the interface is running. 2) In case of the interface is not running before suspending and resuming, the tx does not get resumed by netif_device_attach(). This results in losing network connectivity. It is better to use netif_tx_lock_bh()/netif_tx_unlock_bh() instead for serializing tx routine during reset. This also preserves the symmetry of netif_device_detach() and netif_device_attach(). Fixes commit 713a98d90c5e ("virtio-net: serialize tx routine during reset") Signed-off-by: Ake Koomsin Acked-by: Jason Wang Acked-by: Michael S. Tsirkin Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/virtio_net.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -2162,8 +2162,9 @@ static void virtnet_freeze_down(struct v /* Make sure no work handler is accessing the device */ flush_work(&vi->config_work); + netif_tx_lock_bh(vi->dev); netif_device_detach(vi->dev); - netif_tx_disable(vi->dev); + netif_tx_unlock_bh(vi->dev); cancel_delayed_work_sync(&vi->refill); if (netif_running(vi->dev)) { @@ -2199,7 +2200,9 @@ static int virtnet_restore_up(struct vir } } + netif_tx_lock_bh(vi->dev); netif_device_attach(vi->dev); + netif_tx_unlock_bh(vi->dev); return err; }