Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2276162pxb; Mon, 11 Jan 2021 05:50:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJzCtSSAjPBK/8rbnb6F3S2kJQSDd2OTCjo3mL2VO3jWL/tHCDuW3IHjpaC11YoUE3AdMpRz X-Received: by 2002:a17:907:16a2:: with SMTP id hc34mr11004624ejc.9.1610373045091; Mon, 11 Jan 2021 05:50:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610373045; cv=none; d=google.com; s=arc-20160816; b=TSPhv/MwXZbzUtyV7pN6OUNbwTyCNuPZEDppJsKVHnmtFxPrCGKSdJf2mlQ1lJxiPU jIF4lB93ZLNaPKaKIkrABr85/iDxgeMlbv5noy4/le2HdR3HlJ5OGT7GBB3Q6XQg0wxi IH5RjIqF47A2YLJeyzg8y7BKycHzX8YbfhyQMmnNtrLIa5pOR0uYj2FsIT03uM1AzXuX P/kD9PpBUXyQpTshvjkDLx/KgjSL7ZhxOM1kVU6b2sOeweFfg3w3BHijQuw+Rpc1foPt T/BhEbS306RJQoCXuQXWXST8eN9cr6cSKbn4O50dJgHeydzavnYmp8+S/Hd+CPjsFjcn bo1w== 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=gjEAvHjOpT1T86zjJhw8DjHMc8fhlEqswbafF0WnpfQ=; b=mvaCfQZ+tQeyd5Kw9D700seeY0iRSKL/dHiGkCjrn+FbGBMDVEHn19SeahujFaCpnE Z2/xzKkKaIRPaDgQYtWox38tu7k67KCKkVqRoYY/KF8cVRHqZCTud8CW1BK1T77m9BUm Hh1lYVv0AW65/wLyKTXRo7HUN4C2JdbdgzU7wRBX0tpwynbz5rDNxdce+RckHJS4mTyg oDyjIwIxjHHijZ77DL79qgSUcvjADlWXN1uZ8PWCseqyVCmouv0fKxaBI0XDD/T2vQkV uMlzSkfQ7UWO9dTyk2jOv/deZ/frj/X+38/L6fezV80ac2gRigmMmnlCz3TJu5HqD2qD WluQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Lqt6q6q/"; 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 d10si7041852edk.240.2021.01.11.05.50.21; Mon, 11 Jan 2021 05:50:45 -0800 (PST) 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="Lqt6q6q/"; 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 S1730867AbhAKNqT (ORCPT + 99 others); Mon, 11 Jan 2021 08:46:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:58124 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731292AbhAKNK4 (ORCPT ); Mon, 11 Jan 2021 08:10:56 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 35373225AB; Mon, 11 Jan 2021 13:10:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610370615; bh=63roHdYgYBt958WTj+SmDLqMSGhlEAa+0t7ommF5Q/c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lqt6q6q/HLiZhkOTeTQhuW4hmHw+QnL90AVaxCkywRqnfGhc25q1I7gX5T/h/IUR0 2Nn8XsqhDnHJYUa0zoCr3/YC92FTseopsZahlMzRl30WphrnRgAoaCguJ2x2ouHHy5 mMQnAXIm+izmMkEHgvgh6aZC6Wq8QtBNhMNfWSsA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jeff Dike , Jason Wang , "Michael S. Tsirkin" , Jakub Kicinski Subject: [PATCH 5.4 22/92] virtio_net: Fix recursive call to cpus_read_lock() Date: Mon, 11 Jan 2021 14:01:26 +0100 Message-Id: <20210111130040.220127410@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210111130039.165470698@linuxfoundation.org> References: <20210111130039.165470698@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: Jeff Dike [ Upstream commit de33212f768c5d9e2fe791b008cb26f92f0aa31c ] virtnet_set_channels can recursively call cpus_read_lock if CONFIG_XPS and CONFIG_HOTPLUG are enabled. The path is: virtnet_set_channels - calls get_online_cpus(), which is a trivial wrapper around cpus_read_lock() netif_set_real_num_tx_queues netif_reset_xps_queues_gt netif_reset_xps_queues - calls cpus_read_lock() This call chain and potential deadlock happens when the number of TX queues is reduced. This commit the removes netif_set_real_num_[tr]x_queues calls from inside the get/put_online_cpus section, as they don't require that it be held. Fixes: 47be24796c13 ("virtio-net: fix the set affinity bug when CPU IDs are not consecutive") Signed-off-by: Jeff Dike Acked-by: Jason Wang Acked-by: Michael S. Tsirkin Link: https://lore.kernel.org/r/20201223025421.671-1-jdike@akamai.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/virtio_net.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -2072,14 +2072,16 @@ static int virtnet_set_channels(struct n get_online_cpus(); err = _virtnet_set_queues(vi, queue_pairs); - if (!err) { - netif_set_real_num_tx_queues(dev, queue_pairs); - netif_set_real_num_rx_queues(dev, queue_pairs); - - virtnet_set_affinity(vi); + if (err) { + put_online_cpus(); + goto err; } + virtnet_set_affinity(vi); put_online_cpus(); + netif_set_real_num_tx_queues(dev, queue_pairs); + netif_set_real_num_rx_queues(dev, queue_pairs); + err: return err; }