Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2279949pxb; Mon, 11 Jan 2021 05:57:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJz8UplAPI6ZYr/O0EfuGesBMtGHRkxggny7SJ3gZpRPEim7aUc4nMR+Mh5D5x/IW97nVCbC X-Received: by 2002:a17:906:43c5:: with SMTP id j5mr11360785ejn.530.1610373451759; Mon, 11 Jan 2021 05:57:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610373451; cv=none; d=google.com; s=arc-20160816; b=R24nkNx17ahsdz3IczGHqbhc75mk8Z/izcqTtllNqLq6uaT8eeVkAHYM1wOVdM6Z54 Mh85EI0ImW3UNE0ISEL89LZuHfnJlKL+4jYOyiZM/gri6GKwVNAURfmTceLwQKRHQM2z edk0R+EelFuLyPjzyXj90XvEjkx2LAx/SsZ/n0NNpPSQvakWR8TBf3EPjCa8iwhnoCmr uvIXuShTftOJCCNRgJZ5TAV2DLdu/eNznB/Cs/tIavXDmSf7zWPeiIlF8Fxh2yFhR/xa F+0fXH5/zIr/5GHIg1vIWyOcWfcU70QCwQJMphfOyXPGFZ27b7XSe5PqUda2XcGqhNlV 332Q== 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=VX3lp/4f1bd4yl+7FkFp8jwU67RtyWW+IQ8VYtzm+CA=; b=zbGE7x+ypoWZjC6MSgWS0KSAmZMDgRc6K2Wz1Mz4mlnDjJhHwvn3QhkkLYZABGbRiX D/1D7XafPqRwagAk2mRwBYgthxAs4Sz46kY9OYvZoTtQUqc0nyBhZEjNDCHQn4mCrC5n LYQW4ANF7JD7Uaz+y/BFPLFNscnU4849GARmeJGT2jeDUiMcQuQQJZoxeTvx/hZMliRc y8Uhckkc+m+v25XX5+O/+bFsb2Z4eVNQkvo/C0o8zMjErELG6zWVvbWl028iIvg5mg/z m/HEGSRADMtQQlZqvgEQyD/Tq01dfBTqQG1ngxts4kwy4CAJ3/8aTSL78r+vh3LqESOr qfqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="QKwnv/gJ"; 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 30si7012431edv.385.2021.01.11.05.57.07; Mon, 11 Jan 2021 05:57:31 -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="QKwnv/gJ"; 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 S2388220AbhAKNym (ORCPT + 99 others); Mon, 11 Jan 2021 08:54:42 -0500 Received: from mail.kernel.org ([198.145.29.99]:55254 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728539AbhAKNHv (ORCPT ); Mon, 11 Jan 2021 08:07:51 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 83AE12250F; Mon, 11 Jan 2021 13:07:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610370431; bh=VyYZfqz7pyEM9+NZAw3doltv84BrA+2D3lOrkDVhIgo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QKwnv/gJqQcPQWULtoPmhnYgUsu3mK1ELcMNhZB+E8q04FCdPYfIq+hnmaSsqJs7s D1ksT/mnjywp9FuXAoPersn823P/C98frDGjSQgNKxPtLZ32fMz8+ECKciRUOKee09 3quU/ok38gXHg78Zlb3LDm5ZY/NczlJVNXsER7ts= 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 4.19 19/77] virtio_net: Fix recursive call to cpus_read_lock() Date: Mon, 11 Jan 2021 14:01:28 +0100 Message-Id: <20210111130037.342406655@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210111130036.414620026@linuxfoundation.org> References: <20210111130036.414620026@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 @@ -2077,14 +2077,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; }